簡體   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