1

I know this was answered, but I have some problem, I'm using this solution: link

The only change is that I'm using this in my viewcontroller so replaced self with navigationController!

My problem: the navigation bar is black, not transparent. Am I missing something?

I'm using swift with xcode6.1 and deployment target ios 7.1

Thank you in advance!

EDIT: (code as requested)

override func viewDidLoad() {
    super.viewDidLoad()
    //Transparent navigation bar
    navigationController!.navigationBar.translucent = true
    navigationController!.navigationBar.shadowImage = UIImage()
    navigationController!.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
    /////
    //other stuff
}
Community
  • 1
  • 1
kennyevo
  • 683
  • 4
  • 24
  • Show your code, your statement of replacing `self` with `navigationController!` doesn't clearly explain whether you used `self.navigationController!.` or `navigationController!.` (the former is correct). – A-Live Dec 09 '14 at 10:18
  • `self.navigationController!.` equals with `navigationController!.`, I'm using it in `viewDidLoad()` – kennyevo Dec 09 '14 at 10:26
  • That is about correct, and assuming the app doesn't crash at unwrapping optional `navigationController` your view controller is already at the nav controller stack, then the code should work. Put a breakpoint there to make sure you are actually using this VC class and the code is executed. – A-Live Dec 09 '14 at 10:40
  • Yep, I've tried that, my app does not crash and the code executes (if I remove it, the navbar changes back to the default white translucent as set in the IB) – kennyevo Dec 09 '14 at 10:43
  • Your row code works as expected at the new project though, you either re-set the parameter somewhere or there's some unpredicted layout, you should be able to check the latter easily with view debugging (something like the VC's `view` being placed below the navigation bar and therefore you can see your underlying view or window background through the nav bar). If you aren't familiar with views debugging, try to set different colors for the suspicious components and see what happens (like `UIApplication.sharedApplication().keyWindow?.backgroundColor = UIColor.redColor()`) – A-Live Dec 09 '14 at 10:50
  • ohmygod, The extend edges wasn't enabled in my viewcontroller... Thank you for your help! – kennyevo Dec 09 '14 at 11:50
  • no problem, view debugging rocks :D – A-Live Dec 09 '14 at 11:51

1 Answers1

0

The problem was that in the view controller, the extend under top bar was disabled.

kennyevo
  • 683
  • 4
  • 24