Настройка View Controller в iOS 13 не меняет стиль панели навигации - PullRequest
0 голосов
/ 24 сентября 2019

Я только что создал это расширение UIStoryBoard для изменения атрибутов navBar, единственная проблема в том, что когда я представляю это представление как модальное, стили не меняются, до ios 13 все было правильно,

@objc extension UIStoryboard {
    public func instantitiateChangingNavBar(viewControllerName: String) -> UIViewController {
        let vc = self.instantiateViewController(withIdentifier: viewControllerName)

        if #available(iOS 13.0, *) {
            let barAppareance = UINavigationBarAppearance()

            barAppareance.titleTextAttributes = [.foregroundColor: UIColor.white]
            barAppareance.backgroundColor = UIColor.red
            barAppareance.titleTextAttributes = [.font: UIFont(name: "Akrobat-ExtraBold", size: 18) as Any]

            barAppareance.backButtonAppearance.normal.titleTextAttributes = [.font: UIFont(name: "Akrobat-ExtraBold", size: 18) as Any]
            barAppareance.buttonAppearance.normal.titleTextAttributes = [.font: UIFont(name: "Akrobat-ExtraBold", size: 18) as Any]
            barAppareance.doneButtonAppearance.normal.titleTextAttributes = [.font: UIFont(name: "Akrobat-ExtraBold", size: 18) as Any]

            barAppareance.backButtonAppearance.highlighted.titleTextAttributes = [.font: UIFont(name: "Akrobat-ExtraBold", size: 18) as Any]
            barAppareance.buttonAppearance.highlighted.titleTextAttributes = [.font: UIFont(name: "Akrobat-ExtraBold", size: 18) as Any]
            barAppareance.doneButtonAppearance.highlighted.titleTextAttributes = [.font: UIFont(name: "Akrobat-ExtraBold", size: 18) as Any]

            barAppareance.backButtonAppearance.disabled.titleTextAttributes = [.font: UIFont(name: "Akrobat-ExtraBold", size: 18) as Any]
            barAppareance.buttonAppearance.disabled.titleTextAttributes = [.font: UIFont(name: "Akrobat-ExtraBold", size: 18) as Any]
            barAppareance.doneButtonAppearance.disabled.titleTextAttributes = [.font: UIFont(name: "Akrobat-ExtraBold", size: 18) as Any]

            barAppareance.backButtonAppearance.focused.titleTextAttributes = [.font: UIFont(name: "Akrobat-ExtraBold", size: 18) as Any]
            barAppareance.buttonAppearance.focused.titleTextAttributes = [.font: UIFont(name: "Akrobat-ExtraBold", size: 18) as Any]
            barAppareance.doneButtonAppearance.focused.titleTextAttributes = [.font: UIFont(name: "Akrobat-ExtraBold", size: 18) as Any]

            vc.navigationController?.navigationBar.backgroundColor = UIColor.red
            vc.navigationController?.navigationBar.barStyle = .default
            vc.navigationController?.navigationBar.isTranslucent = false
            vc.navigationController?.navigationBar.standardAppearance = barAppareance
            vc.navigationController?.navigationBar.scrollEdgeAppearance = barAppareance
            vc.navigationController?.navigationBar.compactAppearance = barAppareance

        } else {
            // Fallback on earlier versions
        }
        return vc
    }

}
...