Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWebView under transparent UINavigationBar

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 that all content will be initially pushed after the bar so that it can be seen; thereafter, the user can scroll text and it will underlap the bar.

The problem is that UIWebView appears not to be a proper subclass of UIScrollView; thus, I can't use setContentOffset. Does anyone have any tips or tricks on getting a UIWebView to look good with a translucent navigation bar? Thanks.

like image 208
Jonathan Sterling Avatar asked Sep 16 '09 07:09

Jonathan Sterling


1 Answers

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);
like image 120
zeroimpl Avatar answered Sep 17 '22 13:09

zeroimpl