- (void)viewDidLoad
{
[super viewDidLoad];
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
{
self.edgesForExtendedLayout = UIRectEdgeNone;
self.navigationController.navigationBar.translucent=YES;
}
// Do any additional setup after loading the view.
}
I do not want my scrollView to be behind the navigationBar by default. So I set self.edgesForExtendedLayout = UIRectEdgeNone;.
That viewDidLoad is the mother viewDidLoad of all my viewController.
That's fine. But I like the translucent effect.
It seems that the translucent effect is gone when I set self.edgesForExtendedLayout to none.
How do I set that to none and still got that translucent effect.
I think a good solution would be to arrange the inset of the scrollview.
I did that
- (void)viewDidLoad
{
[super viewDidLoad];
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
{
//self.edgesForExtendedLayout = UIRectEdgeNone;
self.navigationController.navigationBar.translucent=YES;
self.automaticallyAdjustsScrollViewInsets = YES;
}
// Do any additional setup after loading the view.
}
And this is what I got:
I have the same issue right now. So if you need to keep translucent navigation bar you should change not edges but insets. Here is the code, that helps me.
if(floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
CGRect statusBarViewRect = [[UIApplication sharedApplication] statusBarFrame];
float heightPadding = statusBarViewRect.size.height+self.navigationController.navigationBar.frame.size.height;
myContentView.contentInset = UIEdgeInsetsMake(heightPadding, 0.0, 0.0, 0.0);
}
Hope this helps.
Translucent means that the content under the bar can be seen through the translucency. By turning off the extended edges, the translucency is still there, simply you cannot see it because there's not content below.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With