This is the default behaviour for UIViewController
on iOS 7. The view will be full-screen which means the status bar will cover the top of your view.
If you have a UIViewController
within a UINavigationController
and the navigationBar is visible, you can have the following code in your viewDidLoad
or have a background image for navigationBar do the trick.
self.edgesForExtendedLayout = UIRectEdgeNone;
If you have navigationBar hidden, then you have to adjust all the UIView elements by shifting 20 points. I dont't see any other solution. Use auto layout will help a little bit.
Here is the sample code for detecting the iOS version, if you want to backward compatibility.
NSUInteger DeviceSystemMajorVersion() {
static NSUInteger _deviceSystemMajorVersion = -1;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSString *systemVersion = [UIDevice currentDevice].systemVersion;
_deviceSystemMajorVersion = [[systemVersion componentsSeparatedByString:@"."][0] intValue];
});
return _deviceSystemMajorVersion;
}