内容简介:翻译自: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背景颜色?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
YC创业营: 硅谷顶级创业孵化器如何改变世界
兰德尔·斯特罗斯 (Randall Stross) / 苏健 / 浙江人民出版社 / 2014-8-1 / CNY 52.90
在互联网创业成本日益降低、融资却越来越难的今天,硅谷的Y Combinator因何成为全世界创业者趋之若鹜的创业圣地?为什么25岁左右的青年最适合创业?创业者如何才能在遴选面试中脱颖而出?为什么YC特别看好那些主要由黑客组成的创业团队? YC真的歧视女性吗?如何想出能够赢得投资的新点子?创业者应该如何寻找联合创始人? 获准进入Y Combinator及其创业公司全程跟踪批量投资项目的第一人,......一起来看看 《YC创业营: 硅谷顶级创业孵化器如何改变世界》 这本书的介绍吧!