1

I'm new to iOS,

One simple case of my trouble is:

How to place a UILabel (or any UIViews) JUST BELOW a navigation bar and the status bar? The layout is expected to be dynamic(Say these views always stay closely below the nav bar, no matter how the nav bar or the status bar's heights change), like this:

An image for detailed infomation

Some situations have already been considered:

  1. I know that a scrollview is able to layout automatically by using automaticallyAdjustsScrollViewInsets in UIViewController. The case here is not allowed using scrollview though.

  2. The status bar's height can be a constant value of "20" in most iOS device, and the default navigation bar's height can be "44" by the same way. The difference is that I can dynamically get the status bar's height anywhere in the code by using [[UIApplication sharedApplication] statusBarFrame, although the navigation bar's height can be referred by the same "get frame" way, my most cases are to get the height BEFORE the navigation bar gets added into super view, so I always get 0 height from its frame.

  3. Although in most cases the total height of the status bar and the navigation bar can be defined as a value of "64", it is not a eternal way for the future consideration because of more new devices may change this value.

LuRui
  • 111
  • 2
  • 4
  • set label's top constraint to Top Layout Guide – Bhanupriya Feb 23 '17 at 14:19
  • set `viewController.edgesForExtendedLayout = UIRectEdgeNone` more information [here](http://stackoverflow.com/questions/18798792/explaining-difference-between-automaticallyadjustsscrollviewinsets-extendedlayo) – Kamil Harasimowicz Feb 23 '17 at 15:00

0 Answers0