当我使用UIActivityViewController与Whatsapp共享文本时,共享的第二个屏幕的按钮颜色错误。第一个屏幕没问题。这个问题已经讨论了很多次,可以在这里找到一大堆答案:Cannot set text color of Send and Cancel buttons in the mail composer when presented from the UIActivityViewController in iOS7
答案为我修复了按钮颜色:
但由于某些原因不是第二个。
这为第一个屏幕做了修复:
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:[UIColor whiteColor]];
但即使设置所有UIBarButtonItems的外观也不起作用:
[[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]];
示例代码不起作用:
self.window?.tintColor = UIColor.white
let activityController = UIActivityViewController.init(activityItems: items, applicationActivities: nil)
if let vc = delegate?.currentViewController() {
sender.isEnabled = false
vc.present(activityController, animated: true, completion: {
sender.isEnabled = true
})
activityController.navigationController?.navigationBar.tintColor = UIColor.white
activityController.view.tintColor = UIColor.white
截图:
答案 0 :(得分:1)
尝试更改tintColor
方法Appdelegate
中的UIWindow didFinishLaunchingWithOptions
。然后它会自动默认传递给它的所有UIView后代。
[self.window setTintColor:[UIColor whiteColor]];
希望这会对你有所帮助。
这也可能是第三方的一个问题,即(重写)再次设置tintColor。