【问题标题】:Change color of done button in WKWebView在 WKWebView 中更改完成按钮的颜色
【发布时间】:2018-05-03 23:18:41
【问题描述】:

我在 appDelegate 中使用此代码将项目中我的 navigationBar 的所有 UIBarButtonItem 的颜色更改为白色

let whiteAttr = [NSAttributedStringKey.font : UIFont(name: "OpenSans", size: 14)! ,NSAttributedStringKey.foregroundColor: UIColor.white]
UIBarButtonItem.appearance().setTitleTextAttributes(whiteAttr, for: .normal)
UIBarButtonItem.appearance().setTitleTextAttributes(whiteAttr, for: .highlighted)

但是我的 ToolBar 在 WKWebView 中的 Done 按钮也是白色的,我该如何改变颜色?

【问题讨论】:

    标签: ios swift uibarbuttonitem wkwebview uitoolbar


    【解决方案1】:
    let BarButtonItemAppearance = UIBarButtonItem.appearance()
    BarButtonItemAppearance.setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.blue], for: .normal)
    

    【讨论】:

    • 在我看来,这与 OP 的代码非常相似 - 以相同的方式设置 foregroundColor 属性,只是与字体不同。这是关键的区别吗?你能补充一些解释吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-09
    • 2020-08-03
    • 2014-07-11
    相关资源
    最近更新 更多