[英]MFMessageComposeViewController's cancel button color
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.我想使用导航栏的特定图像和状态栏、导航栏的标题和取消按钮的简单白色来自定义
MFMessageComposeViewController
。 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]];
我也尝试使用
[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]
:编辑我终于找到了一个解决方案:只需在最后一个
[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 MFMessageComposeViewController:无法在暗模式下设置“取消”按钮的样式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.