2016-11-03 125 views
3

我目前有一些困难,尝试设置取消和发送按钮的颜色,当我导航到MFMailComposeViewController在iOS 10使用swift 3.我试着设置MFMailComposeViewController的UINavigationController的色调,酒吧和项目没有成功。任何帮助将非常感激。设置导航栏项目颜色在MFMailComposeViewController

What my current MFMailComposeViewController looks like

如何打开MFMailComposeViewController:

/* Open mail for the user to send a help emaail with questions about the app */ 
    func sendEmail() { 

     if MFMailComposeViewController.canSendMail() { 

      let mail = MFMailComposeViewController() 
      mail.mailComposeDelegate = self 
      mail.setToRecipients(["[email protected]"]) 
      mail.navigationBar.tintColor = UIColor.blue 

      present(mail, animated: true) 

     } 
    } 

    /* Called when mail is dismissed */ 
    func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) { 
     controller.dismiss(animated: true) 
    } 
+0

尝试设置撰写控制器的视图本身的色调。 –

+0

@LeoNatan在邮件对象的初始化之前尝试添加'self.navigationController?.navigationBar.tintColor = UIColor.blue',但它没有帮助。 – user3459799

+0

号码试试'mail.view.tintColor = .blue' –

回答

2

如果你想为你的整个应用程序导航的颜色,即按钮的色彩在整个应用程序匹配你可以试试这个:

func application(_ application: UIApplication, didFinishLaunchingWithOptions里面的AppDelegate

// Custom color for navigation bar 
UINavigationBar.appearance().tintColor = UIColor.whateverTintColorYouWant 
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.whateverTextColorYouWant] 

如果你只喜欢本作的MailViewController试试这个:

// Custom color for navigation bar 
mail.navigationController?.navigationBar.tintColor = UIColor.aColorYouwant 
mail.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.aColorYouWant] 
+0

我可以从AppDelegate设置背景和标题颜色。我无法设置按钮的颜色,所以我最终改变了背景和标题颜色,以便与while按钮一起工作,以便它们变得可见。谢谢您的帮助。 – user3459799

相关问题