Изменение цвета заголовка SFSafariViewController - PullRequest
0 голосов
/ 14 декабря 2018

Я использую SFSafariViewController для показа веб-сайта в iphone. Я хочу изменить цветовую схему, как в моем приложении, я хочу изменить цвет заголовка SFSafariViewController вверху.

enter image description here

Ответы [ 3 ]

0 голосов
/ 14 декабря 2018

Попробуйте это

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

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

enter image description here

0 голосов
/ 14 декабря 2018

Нет, вы не можете изменить цвет URL-адреса «Заголовок» для SFSafariViewController.Это представление по умолчанию вашей веб-страницы.Если вы хотите настройки, вы можете использовать WKWebView .

...