UIWebView under transparent UINavigationBar

前端 未结 6 1094
醉酒成梦
醉酒成梦 2021-02-09 21:30

I have a UIWebView which I want to put under my translucent UINavigationBar. Normally when I put a UIScrollView under a translucent UINavigationBar, I set its contentOffset such

6条回答
  •  无人及你
    2021-02-09 22:23

    As of iOS 5 you can use the scrollView property of UIWebView, and set a contentInset to adjust the positon.

    CGFloat top = 0.0;
    
    if( self.navigationController != nil && self.navigationController.navigationBar.translucent ) {
        top = self.navigationController.navigationBar.bounds.size.height;
    }
    
    UIWebView* wv = ...
    
    wv.scrollView.contentInset = UIEdgeInsetsMake(top, 0.0, 0.0, 0.0);
    

提交回复
热议问题