Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: Is is possible to make a UINavigationBar taller and "push" the other views down the screen?

Is there a way to make the "content" area of an iPhone app aware of a larger navigation bar?

Similar to these questions:

  • iOS: Adding a fixed image just below the navigation bar
  • iOS: Positioning navigation bar buttons within custom navigation bar

I've managed to use the 1st questions sample code to add a category on UINavigationBar and change its height, and added a subview where I need it, but I can't see a way to cause the UITableView (or indeed any content views) to take its height into consideration:

iPhone 4 Simulator Screenshot
(The colors are only to make the different views distinguishable)

like image 880
Drarok Avatar asked Jun 21 '11 15:06

Drarok


1 Answers

The accepted answer to the first question sets the nav bar's frame in -layoutSubviews, which is anywhere from "ewwwww" to outright wrong depending on the assumptions made by other layout code.

Instead, override -sizeThatFits: to return a more appropriate size.

like image 136
tc. Avatar answered Oct 22 '22 17:10

tc.