I want to customize MFMessageComposeViewController
with a specific image for the navigation bar and a simple white color for status bar, navigation bar's title and cancel button. The only thing I can't do is to change the cancel button's color. Here is my implementation:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavBar.png"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil]];
MFMessageComposeViewController *sms = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText]){
sms.body = string;
sms.recipients = number;
sms.messageComposeDelegate = self;
[self presentViewController:sms animated:YES completion:^{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}];
}
I also try with [sms.navigationBar setTintColor:[UIColor whiteColor]];
but It doesn't work.
EDIT I finally find a solution: just add this line of code under the last [UINavigationBar appearance]
:
[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil].tintColor = [UIColor whiteColor];
I tried the edit with the solution and it didn't quite work. However, I found a solution with some help:
MFMessageComposeViewController *messageController = [MFMessageComposeViewController new];
[messageController.navigationBar setBarTintColor: [UIColor redColor]];
[self presentViewController:messageController animated:true completion:nil];
[UIView appearanceWhenContainedInInstancesOfClasses:[NSArray arrayWithObject:[MFMessageComposeViewController class]]].tintColor = [UIColor redColor];
MFMessageComposeViewController: Cannot Style "Cancel" Button in Dark Mode
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.