1

On my main view controller is laid out a UITableView just under the navigation bar.

In my AppDelegate, I do some setup for the navigation bar in general as following:

UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: false)

let navigationBarAppearace = UINavigationBar.appearance()

navigationBarAppearace.tintColor = UIColor.whiteColor()
navigationBarAppearace.barStyle = .Black
navigationBarAppearace.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor()]

With this setup, when I call this on my first cell of my table view in my main view controller

let cellFrame = tableView.convertRect(cell.frame, toView: tableView.superview)

I get the following frame:

cellFrame : (0.0, 64.0, 375.0, 268.0)

Which is what I expect to get. Then, when I add the following in my setup in my AppDelegate:

navigationBarAppearace.translucent = false

then I get the following frame:

cellFrame : (0.0, 0.0, 375.0, 268.0)

The y origin is now 0.

Can someone explain me why?

Nilesh
  • 701
  • 5
  • 14
Nico
  • 6,269
  • 9
  • 45
  • 85
  • 1
    [http://stackoverflow.com/questions/17074365/status-bar-and-navigation-bar-appear-over-my-views-bounds-in-ios-7?rq=1](this) may help you. – Bharat Nov 03 '15 at 07:37
  • I tried but it doesn't work. My `tableView.frame.minY` still equals 0 – Nico Nov 03 '15 at 08:07
  • My bad, I didn't try all the possibilities. Doing `self.extendedLayoutIncludesOpaqueBars = true` in viewDidLoad of my main view controller fixed it. Which is weird as they say the opposite in the doc: `If your design uses opaque bars, refine edgesForExtendedLayout by also setting the extendedLayoutIncludesOpaqueBars property to NO` – Nico Nov 03 '15 at 08:10

0 Answers0