[英]How to change NavigationController text color when Cancel button is pressed on UIActivityViewController?
The color text is white for NavigationController text but changing it to white when a user presses the share button (to show cancel button). 对于NavigationController文本,彩色文本为白色,但是当用户按下共享按钮(以显示取消按钮)时,将其更改为白色。 But when user press cancel button and returns from text composing then the color remains same and not change back to white.
但是,当用户按下“取消”按钮并从组成文本的内容返回时,颜色保持不变,并且不会变回白色。
The completion handler is detected as I see the print in the log but it doesn't change the color. 当我在日志中看到打印内容时,检测到完成处理程序,但它不会更改颜色。
func completionHandler(activityType: UIActivityType?, shared: Bool, items: [Any]?, error: Error?) {
if (shared) {
print("Cool user shared some stuff")
}
else {
print("Bad user canceled sharing :(")
UIButton.appearance(whenContainedInInstancesOf: [UINavigationBar.self]).tintColor = .white
navigationController?.navigationBar.largeTitleTextAttributes = [
NSAttributedStringKey.foregroundColor : UIColor.white
]
navigationController?.navigationBar.titleTextAttributes = [
NSAttributedStringKey.foregroundColor : UIColor.white
]
}
}
Removed completion handler and all the code related to changing color for tint color and only added the following to search bar. 删除了完成处理程序和所有与更改颜色以更改颜色相关的代码,仅在搜索栏中添加了以下内容。
UIBarButtonItem.appearance(whenContainedInInstancesOf: [UISearchBar.self]).tintColor = .white
If I click on Search Bar now the cancel button color is white and when I share content through Message the composing text "cancel" button color is the default (blue). 如果现在单击搜索栏,则取消按钮的颜色为白色,而当我通过“消息”共享内容时,编写的文本“取消”按钮的颜色为默认(蓝色)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.