I'm using SFSafariViewController for show website in iphone i want to change color scheme like my app, i want to change color of SFSafariViewController title at top.
Asked
Active
Viewed 1,486 times
1
-
Possible duplicate of [Change tintcolor of SFSafariViewController?](https://stackoverflow.com/questions/31913683/change-tintcolor-of-sfsafariviewcontroller) – Mateusz Dec 14 '18 at 12:07
-
Check it https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/2274393-preferredcontroltintcolor – Kathiresan Murugan Dec 14 '18 at 12:08
-
@ktr *preferredBarTintColor The color to tint the background of the navigation bar and the toolbar. – Umer Afzal Dec 14 '18 at 12:12
-
1@ktrkathir *preferredControlTintColor The color to tint the control buttons on the navigation bar and the toolbar. – Umer Afzal Dec 14 '18 at 12:13
-
Not mention title color – Umer Afzal Dec 14 '18 at 12:13
3 Answers
1
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)]
}
I was updated my navigation bar then i call my safariService function its working fine for me.

Kathiresan Murugan
- 2,783
- 3
- 23
- 44
0
No, you cannot change the URL "Title" color for SFSafariViewController. Its a default view of your web page. If you want the customisation you can use WKWebView.

Huzaifa ameen
- 143
- 1
- 8
0
Try this
UINavigationBar.appearance().backgroundColor = UIColor.green
UINavigationBar.appearance().tintColor = UIColor.red
let attrs = [
NSForegroundColorAttributeName: UIColor.red
]
UINavigationBar.appearance().titleTextAttributes = attrs
Source : https://github.com/zendesk/zendesk_sdk_chat_ios/issues/130

dahiya_boy
- 9,298
- 1
- 30
- 51