Leonardo
Leonardo

Reputation: 228

Swift Transparent UINavigationBar

I've to make my navigation bar transparent, I tried with this code :

self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.isTranslucent = true
self.navigationController?.view.backgroundColor = UIColor.clear

But my navigation bar become white, I don't understand the reason! Can someone help to solve this problem?

Upvotes: 0

Views: 296

Answers (1)

trungduc
trungduc

Reputation: 12144

You are doing right way to make transparent UINavigationBar but seem like you have a wrong constraint. Make sure you top constraint of your scrollView is equal to Superview.Top.

enter image description here

If your top constraint of your scrollView is equal to Safe Area.Top, of course your ScrollView won't scroll below UINavigationBar.

enter image description here

Upvotes: 1

Related Questions