1

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

clover4leaf
  • 33
  • 1
  • 5

2 Answers2

3

Modify the appearance code to this :-

let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()
appearance.shadowColor = .clear
appearance.backgroundColor = .clear
appearance.backgroundImage = nil
appearance.shadowImage = nil
Vincent Joy
  • 2,598
  • 15
  • 25
  • 2
    You can cut the last 4 lines. They are identical to saying configureWithTransparentBackground, and you’ve said that. – matt Jun 01 '20 at 12:30
1

Works for me:

self.compactAppearance = appearance
self.standardAppearance = appearance
self.scrollEdgeAppearance = appearance
self.backgroundColor = appearance.backgroundColor
clover4leaf
  • 33
  • 1
  • 5