简体   繁体   English

MFMessageComposeViewController 的取消按钮颜色

[英]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.

相关问题 MFMessageComposeViewController 取消按钮不起作用 - MFMessageComposeViewController cancel button not working 取消在蓝色导航栏中的MFMessageComposeViewController上不可见 - Cancel not visible on MFMessageComposeViewController in blue color navigation bar MFMessageComposeViewController显示没有取消按钮和标题 - MFMessageComposeViewController showed without cancel button and title 如何在MFMessageComposeViewController的搜索栏中访问“+”添加按钮的颜色 - How do I access to color of '+' add button in searchbar of MFMessageComposeViewController UISearchBar 取消按钮颜色? - UISearchBar cancel button color? 如何更改UISearchbar取消按钮的文本颜色 - How do I change the UISearchbar cancel button's text color uialertaction取消按钮中的背景色 - Background color in uialertaction cancel button 在MFMessageComposeViewController上设置NavigationBar背景色 - Set NavigationBar background color on MFMessageComposeViewController 在MFMessageComposeViewController中点击取消后没有任何反应 - After hitting cancel in a MFMessageComposeViewController nothing happens 更改文本后,无法更改UISearchBar取消按钮标题颜色。 - Unable to change UISearchBar cancel button title color after changing it's text.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM