内容简介:翻译自: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背景颜色?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Learn Python the Hard Way
Zed A. Shaw / Addison-Wesley Professional / 2013-10-11 / USD 39.99
Master Python and become a programmer-even if you never thought you could! This breakthrough book and CD can help practically anyone get started in programming. It's called "The Hard Way," but it's re......一起来看看 《Learn Python the Hard Way》 这本书的介绍吧!