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
With the advent of iOS 7, the offset height would now need to include the height of the top status area. Otherwise, iOS7 devices will have 20 pixels of webview still hidden under the navigation bar.
In a project that needs to support iOS 7 and older devices, a macro like the one found here:
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
Can be very useful. A modified version of zerotool's helpful code listed above could now look something like this:
if (self.navigationController != nil && self.navigationController.navigationBar.translucent) {
top = self.navigationController.navigationBar.bounds.size.height;
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
top += [[UIScreen mainScreen] applicationFrame].origin.y;
}
}
// (etc.)