2016-11-03 71 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

相關問題