首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SFSafariViewController标题颜色更改

SFSafariViewController标题颜色更改
EN

Stack Overflow用户
提问于 2018-12-14 19:53:51
回答 3查看 1K关注 0票数 0

我在iphone中使用SFSafariViewController显示网站,我想像我的应用程序一样改变配色方案,我想改变顶部SFSafariViewController标题的颜色。

EN

回答 3

Stack Overflow用户

发布于 2018-12-14 20:26:11

代码语言:javascript
复制
import SafariServices

extension UIViewController {

    /// Safari Service ViewController with
    /// - parameter link: initial load url
    func openSafariService(withURL link: String) {

        //  let url = link.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)

        if link.isNotBlank {
            let safariVC = SFSafariViewController(url: URL(string: link)!, entersReaderIfAvailable: true)
            safariVC.preferredBarTintColor = UIColor.themeBlue
            safariVC.preferredControlTintColor = UIColor.white
            self.present(safariVC, animated: true, completion: nil)
        }

    }
}

// Update navigation bar
func updateNavigationBar() {
     navigationController?.navigationBar.barTintColor = UIColor.themeBlue
     navigationController?.navigationBar.tintColor = UIColor.white
     navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white,
                                                                       NSAttributedStringKey.font: UIFont.customFont(size: 17.0)]
}

我更新了我的导航栏,然后调用了我的safariService函数,它对我来说工作得很好。

票数 1
EN

Stack Overflow用户

发布于 2018-12-14 20:13:30

不能,您不能更改SFSafariViewController的URL“标题”颜色。这是你的网页的默认视图。如果你想要定制,你可以使用WKWebView

票数 0
EN

Stack Overflow用户

发布于 2018-12-14 20:22:27

尝尝这个

代码语言:javascript
复制
UINavigationBar.appearance().backgroundColor = UIColor.green
UINavigationBar.appearance().tintColor = UIColor.red
let attrs = [
      NSForegroundColorAttributeName: UIColor.red
]
UINavigationBar.appearance().titleTextAttributes = attrs

来源:https://github.com/zendesk/zendesk_sdk_chat_ios/issues/130

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53779276

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档