简体   繁体   English

当在UIActivityViewController上单击“取消”按钮时,如何更改NavigationController的文本颜色?

[英]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.

相关问题 UIActivityViewController - 如何更改取消按钮文本 - UIActivityViewController - how to change the cancel button text UIActivityViewController中缺少取消按钮文本 - Missing cancel button text in UIActivityViewController UISearchbar添加navigationController?.navigationBar,如何更改“取消”颜色 - UISearchbar add navigationController?.navigationBar,How to change “Cancel” color 如何在按下按钮时更改按钮的颜色,并在按下其他按钮时重置为原始颜色? - How do I change a button's color when pressed and reset to original color when a different button is pressed? 按下下一个按钮时如何更改上一个按钮的颜色? - How to Change previous button color when pressed the next button? 更改 UIActivityViewController 编辑按钮颜色 - Change UIActivityViewController Edit button color 如何更改UISearchbar取消按钮的文本颜色 - How do I change the UISearchbar cancel button's text color iOS UIActivityViewController取消按钮中缺少文本 - Missing Text in iOS UIActivityViewController Cancel Button 如何在UIActivityViewController中更改文本颜色和图标颜色 - How do I change the text color and icon color in UIActivityViewController 使用TouchableHighlight在React Native中按下时如何更改按钮颜色? - How to change button color when pressed in React Native using TouchableHighlight?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM