美文网首页iOS学习
解决webview页面遮挡状态栏

解决webview页面遮挡状态栏

作者: 斑驳的流年无法释怀 | 来源:发表于2018-07-02 16:55 被阅读682次

场景如下:


image.png

解决方案:控制webview的frame,顶部添加20的view

代码如下:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    UIView *statusBarView = [[UIView alloc]   initWithFrame:CGRectMake(0, 0,    self.view.bounds.size.width, 20)];
    statusBarView.backgroundColor = [HTMISettingManager manager].navigationBarColor;
    [self.view addSubview:statusBarView];
}
- (void)viewWillAppear:(BOOL)animated
{
     CGRect viewBounds = [self.webView bounds];
     viewBounds.origin.y = 20;
     viewBounds.size.height = viewBounds.size.height - 20;
     self.webView.frame = viewBounds;
    [super viewWillAppear:animated];
}

相关文章

网友评论

    本文标题:解决webview页面遮挡状态栏

    本文链接:https://www.haomeiwen.com/subject/wbikuftx.html