MFMessageComposeViewController的取消按钮颜色

时间:2017-04-09 20:45:39

标签: ios mfmessagecomposeview

我想使用导航栏的特定图像和状态栏,导航栏标题和取消按钮的简单白色自定义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];

0 个答案:

没有答案