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

发布于 2018-12-14 20:26:11
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函数,它对我来说工作得很好。

发布于 2018-12-14 20:13:30
不能,您不能更改SFSafariViewController的URL“标题”颜色。这是你的网页的默认视图。如果你想要定制,你可以使用WKWebView。
发布于 2018-12-14 20:22:27
尝尝这个
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
https://stackoverflow.com/questions/53779276
复制相似问题