use*_*799 5 uinavigationbar uinavigationcontroller swift swift3
当我使用 swift 3 在 iOS 10 中导航到 MFMailComposeViewController 时,我目前在尝试设置取消和发送按钮颜色时遇到了一些困难。我尝试设置 MFMailComposeViewController 的 UINavigationController、Bar 和 Items 的色调,但没有成功。任何帮助将非常感激。
我如何打开 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(["himom@gmail.com"])
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)
}
Run Code Online (Sandbox Code Playgroud)
如果您想要整个应用程序的导航颜色,即按钮的色调在整个应用程序中匹配,您可以尝试以下操作:
里面func application(_ application: UIApplication, didFinishLaunchingWithOptions的AppDelegate
// Custom color for navigation bar
UINavigationBar.appearance().tintColor = UIColor.whateverTintColorYouWant
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.whateverTextColorYouWant]
Run Code Online (Sandbox Code Playgroud)
如果您只想为 MailViewController 尝试此操作:
// Custom color for navigation bar
mail.navigationController?.navigationBar.tintColor = UIColor.aColorYouwant
mail.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.aColorYouWant]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2103 次 |
| 最近记录: |