繁体   English   中英

MFMessageComposeViewController 的取消按钮颜色

[英]MFMessageComposeViewController's cancel button color

我想使用导航栏的特定图像和状态栏、导航栏的标题和取消按钮的简单白色来自定义MFMessageComposeViewController 我唯一不能做的就是改变取消按钮的颜色。 这是我的实现:

[[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];
    }];
}

我也尝试使用[sms.navigationBar setTintColor:[UIColor whiteColor]]; 但它不起作用。

编辑我终于找到了一个解决方案:只需在最后一个[UINavigationBar appearance]下添加这行代码:

[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil].tintColor = [UIColor whiteColor];

我尝试使用解决方案进行编辑,但效果不佳。 但是,我在一些帮助下找到了解决方案:

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:无法在暗模式下设置“取消”按钮的样式

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM