颜色 – iOS 10无法再在MFMessageComposeViewController上设置barcolor和tint

以下代码适用于iOS 9.x或更低版本,由于某些原因,如果iOS 10不起作用
if([MFMessageComposeViewController canSendText])
             {
                 controller.body = message;
                 Nsstring *tel = pContact.tlc;
                 controller.recipients = pContact.tlc?@[tel]:nil;
                 controller.messageComposeDelegate = self;
                 controller.navigationBar.tintColor = [UIColor whiteColor];
                 controller.navigationBar.barTintColor = [UIColor blueColor];
                 [self presentViewController:controller animated:YES completion:nil];
             }

是破坏还是做了一些改变.不知道这里丢失什么我在黑暗中(黑色黑色)

编辑:
我试图在一个新的空单视图项目上使用一些测试代码,我遇到了同样的问题.

@IBAction func SMS(_ sender: AnyObject) {
        let composeVC = MFMessageComposeViewController()
        composeVC.messageComposeDelegate = self

        // Configure the fields of the interface.
        composeVC.recipients = ["5555555555"]
        composeVC.body = "Hello from California!"
        composeVC.navigationBar.tintColor = UIColor.green
        composeVC.navigationBar.barTintColor = UIColor.purple
        // Present the view controller modally.
        self.present(composeVC,animated: true,completion: nil)
    }

编辑:
UINavigationBar外观可以在测试应用程序的背景或barTint中设置颜色,但是我仍然无法设置测试应用程序的文本颜色.我正在使用的应用程序使用UINavigationBar外观已经在应用程序中设置导航栏颜色,但这并不影响SMS的导航栏,因为它出现了白色背景和白色文本.无法更改文本颜色或背景颜色,使此视图不可用.

解决方法

在iOS 10之前,我正在使用UINavigationBar的外观代理,像这样:
NSDictionary* titleAttribs = @{ NSForegroundColorAttributeName: [ColoursAndStyles sharedInstance].fontColourNavBarTitle,NSFontAttributeName: [ColoursAndStyles sharedInstance].fontNavbarBoldTitle };

[[UINavigationBar appearance] setBarTintColor:[ColoursAndStyles sharedInstance].viewColourNavBarMain];
[[UINavigationBar appearance] setTintColor:[ColoursAndStyles sharedInstance].viewColourNavBarTint];
[[UINavigationBar appearance] setTitleTextAttributes:titleAttribs];

这覆盖了我对MFMessageComposeViewController的使用,其中setTitleTextAttributes处理标题/标题文本颜色.

使用iOS 10,我正在使用以下工作.在我提交MFMessageComposeViewController之前,我更改标题文本属性.例如.:

- (void)sendTap:(id)s
{
    // some code...

    NSDictionary* newTitleAttribs = @{ NSForegroundColorAttributeName: [ColoursAndStyles sharedInstance].fontColourTitleStrip,NSFontAttributeName: [ColoursAndStyles sharedInstance].fontNavbarBoldTitle };

    [[UINavigationBar appearance] setTitleTextAttributes:newTitleAttribs];

    // present the MFMessageComposeViewController...
}

然后,当MFMessageComposeViewController完成时,将其重新设置为我想要的应用程序的其余部分,例如:

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
    NSDictionary* titleAttribs = @{ NSForegroundColorAttributeName: [ColoursAndStyles sharedInstance].fontColourNavBarTitle,NSFontAttributeName: [ColoursAndStyles sharedInstance].fontNavbarBoldTitle };

    [[UINavigationBar appearance] setTitleTextAttributes:titleAttribs];

    // some code...

    [controller dismissViewControllerAnimated:YES completion:^{
        // some code...
    }];
}

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...