【发布时间】:2016-07-08 23:17:46
【问题描述】:
我通过将 Info.plist 中的 view-controller based status bar 设置为 No 将状态栏设置为浅色内容,因为我使用深色作为导航栏。我能够使用AppDelegate.swift 中的以下代码设置导航栏颜色和栏按钮项颜色和字体 -
UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent
UINavigationBar.appearance().barTintColor = UIColor.darkGrayColor()
UINavigationBar.appearance().translucent = false
if #available(iOS 8.2, *) {
UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName : UIFont.systemFontOfSize(16.0, weight: UIFontWeightThin)], forState: UIControlState.Normal)
UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName : UIFont.systemFontOfSize(23.0, weight: UIFontWeightThin), NSForegroundColorAttributeName: UIColor.whiteColor()]
} else {
// Fallback on earlier versions
}
if #available(iOS 9.0, *) {
UIBarButtonItem.appearanceWhenContainedInInstancesOfClasses([UINavigationBar.self]).tintColor = UIColor.whiteColor()
UIBarButtonItem.appearanceWhenContainedInInstancesOfClasses([UINavigationBar.self]).setTitleTextAttributes([NSFontAttributeName : UIFont.systemFontOfSize(16.0, weight: UIFontWeightThin)], forState: UIControlState.Normal)
} else {
// Fallback on earlier versions
}
我有以下几个问题:-
- 我无法为共享活动设置导航栏颜色 -
UIActivityViewController上的 Skype、收件箱(Gmail 邮件应用程序) - 无法设置 barButtonItem,例如使用
UIBarButtonItem.appearanceWhenContainedInInstancesOfClasses([UINavigationBar.self]).setTitleTextAttributes([NSFontAttributeName : UIFont.systemFontOfSize(16.0, weight: UIFontWeightThin)], forState: UIControlState.Normal)“取消”字体和大小
我尝试在 UIActivityViewController 的完成块中编写相同的代码,但没有任何效果。
当我在 whatsapp 共享活动中从最近聊天中选择一个聊天时,barbuttonitem 颜色变为默认蓝色 - See Snapshot
首先,我使用的解决方案支持 iOS 8.0、8.2 或更高版本。对于从 7.0 或 7.1 开始的版本,我想实现所有相同的目标。我该怎么做?
【问题讨论】:
标签: ios uinavigationcontroller uinavigationbar uibarbuttonitem uiactivityviewcontroller