内容简介:翻译自:https://stackoverflow.com/questions/19417058/how-can-i-change-the-uiwebview-background-color-after-sliding-down-uiwebview-to
我正在写一个Phonegap 3.0应用程序.
iOS7中的状态栏重叠视图存在问题,即用户 Ludwig Kristoffersson provided a working answer here
现在我的UIWebView具有20px的上边距,我该如何更改UIWebView背景颜色?我需要状态栏后面的区域与“人物”工具栏的背景颜色相同.
我几乎没有Objective C的经验,并且一直在寻找可能的SO问题来找到一个有效的解决方案,但没有成功.
下面是我到目前为止尝试过的代码:
- (void)viewWillAppear:(BOOL)animated {
//Lower screen 20px on ios 7
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
CGRect viewBounds = [self.webView bounds];
viewBounds.origin.y = 20;
viewBounds.size.height = viewBounds.size.height - 20;
self.webView.frame = viewBounds;
[self.webView setOpaque:YES];
//neither of these seem to work when uncommented:
// [self.webView setBackgroundColor:[UIColor grayColor]];
// self.webView.backgroundColor=[UIColor grayColor];
}
[super viewWillAppear:animated];
}
更新1
- (void)viewWillAppear:(BOOL)animated
{
//Lower screen 20px on ios 7
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
CGRect viewBounds = [self.webView bounds];
viewBounds.origin.y = 20;
viewBounds.size.height = viewBounds.size.height - 20;
self.webView.frame = viewBounds;
self.webView.backgroundColor = [UIColor grayColor];
self.webView.opaque=NO;
}
[super viewWillAppear:animated];
}
这似乎仍然给我一个状态栏背后的白色背景,而不是灰色.
我希望的结果是这样的:
将Opaque属性更改为NO并检查如下:
self.webView.backgroundColor = [UIColor grayColor]; self.webView.opaque=NO;
它对我来说很好.
翻译自:https://stackoverflow.com/questions/19417058/how-can-i-change-the-uiwebview-background-color-after-sliding-down-uiwebview-to
以上所述就是小编给大家介绍的《在向下滑动UIWebView以修复iOS7状态栏覆盖问题后,如何更改UIWebView背景颜色?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
30天自制操作系统
[日] 川合秀实 / 周自恒、李黎明、曾祥江、张文旭 / 人民邮电出版社 / 2012-8 / 99.00元
自己编写一个操作系统,是许多程序员的梦想。也许有人曾经挑战过,但因为太难而放弃了。其实你错了,你的失败并不是因为编写操作系统太难,而是因为没有人告诉你那其实是一件很简单的事。那么,你想不想再挑战一次呢? 这是一本兼具趣味性、实用性与学习性的书籍。作者从计算机的构造、汇编语言、C语言开始解说,让你在实践中掌握算法。在这本书的指导下,从零编写所有代码,30天后就可以制作出一个具有窗口系统的32位......一起来看看 《30天自制操作系统》 这本书的介绍吧!