Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Image Underlay of Transparent Navigation Bar and Status Bar in Swift iOS 8

Tags:

ios

swift

I am new in iOS swift development and I am facing a problem. I want to set transparent navigation bar and make image underlay of transparent navigation bar and status bar like image below,

enter image description here

But after I implemented the following code,

self.navigationController!.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
self.navigationController!.navigationBar.shadowImage = UIImage()
self.navigationController!.navigationBar.translucent = true

The result is image still below navigation bar and status bar even though I set the navigation bar to transparent.

enter image description here

like image 215
taufan Avatar asked Jul 14 '15 06:07

taufan


1 Answers

I have tried same code as you provided:

override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationController!.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
    self.navigationController!.navigationBar.shadowImage = UIImage()
    self.navigationController!.navigationBar.translucent = true
}

And it is working fine and you can see result here:

enter image description here

Check my sample project and find out what are you missing.

Hope it will help.

like image 109
Dharmesh Kheni Avatar answered Oct 04 '22 15:10

Dharmesh Kheni