I inherited an outdated application and was instructed to update it for iOS 11. In one view, a user can click on a name and add this user to his contacts. However, by switching to "add contact" mode in iOS 11, the navigation and status bars appear as white. It works great on iOS 10 and below.
Here is a screenshot comparing iOS 10 (left) and iOS 11 (right):
Note that this view is created programmatically, and not through the storyboard:
ABRecordRef person = ABPersonCreate();
ABNewPersonViewController *newPersonViewController = [[ABNewPersonViewController alloc] init];
[newPersonViewController setDisplayedPerson:person];
newPersonViewController.newPersonViewDelegate = self;
UINavigationController *newNavigationController = [[UINavigationController alloc] initWithRootViewController:newPersonViewController];
[self presentViewController:newNavigationController animated:YES completion:nil];
CFRelease(person);
I tried several different things based on what I found on the Internet:
- I found that I can manually set the background color in the navigation bar, but this leaves the status bar white.
- HeightConstraint . , , . , ( 0, 100, 1000 ) . , , .
- , iOS 11 status/nav SetContentInsetAdjustmentBehavior NEVER. , ScrollViews TableViews. UIView.
- CNContactViewController ( ABNewPersonViewController ) .
.
: AppDelegate didFinishLaunchingWithOptions, . , . , .
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if ([MPUtils isIOS7OrHigher]) {
[[UIToolbar appearance] setBarTintColor:[MPColors colorWithColorString:MPColorString0A3B77]];
[[UINavigationBar appearance] setBarTintColor:[MPColors colorWithColorString:MPColorString0A3B77]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTitleTextAttributes:@{UITextAttributeTextColor : [UIColor whiteColor]}];
} else {
[[UIToolbar appearance] setTintColor:[MPColors colorWithColorString:MPColorString0A3B77]];
[[UINavigationBar appearance] setTintColor:[MPColors colorWithColorString:MPColorString0A3B77]];
}
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
[MPUserDataSynchronizer syncUserData];
return YES;
}