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, которая прекрасно работает для меня.