Ios SFSafariViewController标题颜色更改
我正在使用iphone中的SFSafariViewController用于显示网站。我想像我的应用程序一样更改配色方案,我想更改顶部SFSafariViewController标题的颜色Ios SFSafariViewController标题颜色更改,ios,sfsafariviewcontroller,Ios,Sfsafariviewcontroller,我正在使用iphone中的SFSafariViewController用于显示网站。我想像我的应用程序一样更改配色方案,我想更改顶部SFSafariViewController标题的颜色 否,您不能更改SFSafariViewController的URL“Title”颜色。这是网页的默认视图。如果您想要定制,您可以使用 试试这个 UINavigationBar.appearance().backgroundColor = UIColor.green UINavigationBar.appeara
否,您不能更改SFSafariViewController的URL“Title”颜色。这是网页的默认视图。如果您想要定制,您可以使用 试试这个
UINavigationBar.appearance().backgroundColor = UIColor.green
UINavigationBar.appearance().tintColor = UIColor.red
let attrs = [
NSForegroundColorAttributeName: UIColor.red
]
UINavigationBar.appearance().titleTextAttributes = attrs
资料来源:
我更新了我的导航栏,然后我调用了我的safariService功能,这对我来说很好
Check it@ktr*PreferredBartinColor可能重复用于着色导航栏和工具栏背景的颜色。@ktrkathir*preferredControlTintColor用于着色导航栏和工具栏上的控制按钮的颜色。更不用说标题颜色了
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)]
}