1

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.

enter image description here

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Umer Afzal
  • 371
  • 1
  • 2
  • 18

3 Answers3

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.

enter image description here

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