clover4leaf
clover4leaf

Reputation: 33

Transparent navigation bar iOS 13

Can't create transparent NavigationBar iOS 13.

I have custom UINavigationBar, where I configure UINavigationBarAppearance in

override init(frame: CGRect) {
    super.init(frame: frame)
    self.configure()
}

required init?(coder: NSCoder) {
    super.init(coder: coder)
    self.configure()
}

Configuration code:

let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()
appearance.shadowColor = .clear
appearance.backgroundColor = .clear

And set it to:

self.compactAppearance = appearance
self.standardAppearance = appearance
self.scrollEdgeAppearance = appearance

And by the result I have this:

enter image description here

Expected result: NavigationBar should be transparent

Upvotes: 1

Views: 3819

Answers (2)

clover4leaf
clover4leaf

Reputation: 33

Works for me:

self.compactAppearance = appearance
self.standardAppearance = appearance
self.scrollEdgeAppearance = appearance
self.backgroundColor = appearance.backgroundColor

Upvotes: 1

Vincent Joy
Vincent Joy

Reputation: 2678

Modify the appearance code to this :-

let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()
appearance.shadowColor = .clear
appearance.backgroundColor = .clear
appearance.backgroundImage = nil
appearance.shadowImage = nil

Upvotes: 4

Related Questions