微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法在 MFMessageComposeController 中设置更改取消按钮的颜色

如何解决无法在 MFMessageComposeController 中设置更改取消按钮的颜色

我正在尝试通过单击按钮来呈现一个简单的 MFMessageComposeController。一切正常,但我无法更改取消的颜色,也无法从 iOS 13 全屏显示

我用代码试过

messageController.navigationBar.tintColor = [UIColor greenColor];
messageController.navigationBar.barTintColor = [UIColor blueColor];

以及制作全屏

messageController.modalPresentationStyle = UIModalPresentationFullScreen;

但是没有用。完整代码在这里

 #import "MessageViewController.h"
#import <MessageUI/MessageUI.h>

@interface MessageViewController ()<MFMessageComposeViewControllerDelegate>

@end

@implementation MessageViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (IBAction)sendMessage:(UIButton *)sender {
    [self.view endEditing:YES]; 
    if([MFMessageComposeViewController canSendText]) {
        MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init]; // Create message VC
        messageController.navigationBar.tintColor = [UIColor greenColor];
        messageController.navigationBar.barTintColor = [UIColor blueColor];
        
        
        messageController.messageComposeDelegate = self; // Set delegate to current instance

        NSMutableArray *recipients = [[NSMutableArray alloc] init]; // Create an array to hold the recipients
        [recipients addobject:@"555-555-5555"]; // Append example phone number to array
        messageController.recipients = recipients; // Set the recipients of the message to the created array

        messageController.body = @"Example message"; // Set initial text to example message
        // disabling the select recepient by adding the transparent view overit
        dispatch_async(dispatch_get_main_queue(),^{ // Present VC when possible
            [self presentViewController:messageController animated:YES completion:^{
                 UIView* paintView=[[UIView alloc]initWithFrame:CGRectMake(0,50,messageController.view.frame.size.width,60)];
                 UIColor *myColor = [[UIColor whiteColor] colorWithAlphaComponent:0.3f];
                [paintView setBackgroundColor: myColor];
                   paintView.userInteractionEnabled = false;
                   [messageController.view addSubview:paintView];
            }];
        });
    }
}

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
    [self dismissViewControllerAnimated:YES completion:NULL];
}


@end

这是我得到的结果。如何在 iOS 13 及更高版本中更改取消颜色并使 MFMessageComposer 全屏显示

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。