For some reason, my UIWindow
's rootViewController
is having its margins set to 16 on the left and right, and 0 on the top and bottom. Unfortunately I'm working with a legacy (read: non-storyboard) application that initializes everything manually. This affects view controllers many layers deep, which insist on having a bottom margin of 0.
I have this code in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Code
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.rootViewController = [[UIViewController alloc] init];
[self.window makeKeyAndVisible];
UIEdgeInsets insets = self.window.layoutMargins;
NSLog(@"Left %f, Right %f, Bottom %f, Top %f", insets.left, insets.right, insets.bottom, insets.top);
insets = self.window.rootViewController.view.layoutMargins;
NSLog(@"Left %f, Right %f, Bottom %f, Top %f", insets.left, insets.right, insets.bottom, insets.top);
Producing the following output
2016-08-03 18:10:24.280 app[426:182429] Left 8.000000, Right 8.000000, Bottom 8.000000, Top 8.000000
2016-08-03 18:10:24.280 app[426:182429] Left 16.000000, Right 16.000000, Bottom 0.000000, Top 0.000000
Edit
I have finally found that this is the expected behavior. When I push a new UIViewController, though, I am surprised that no bottom margin is added. Is this expected behavior? Should I never expect to have a bottom margin in iOS?