Попытка установить прозрачную панель навигации, но она отображается черным - PullRequest
0 голосов
/ 23 октября 2018

Я пытался получить прозрачный navigationBar, но он становится черным.Вот код, который я использовал, чтобы сделать его прозрачным:

navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.navigationBar.isTranslucent = true

Любая помощь очень ценится. enter image description here

1 Ответ

0 голосов
/ 23 октября 2018

Вы можете попробовать это UINavigationBar расширение

Использовать

navigationController?.navigationBar.makeTransparent()

Расширение

public extension UINavigationBar {

    /// - Parameter tint: tint color (default is .white).
    public func makeTransparent(withTint tint: UIColor = .white) {
        setBackgroundImage(UIImage(), for: .default)
        shadowImage = UIImage()
        isTranslucent = true
        tintColor = tint
        titleTextAttributes = [NSAttributedStringKey.foregroundColor: tint]
    }

}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...