Getting Autolayout under the status bar

I have read several previous posts about Autolayout and status bar behavior in iOS 7 and still don't know how to get Autolay-ed out objects under the status bar.

I currently have

self.automaticallyAdjustsScrollViewInsets = YES;
self.edgesForExtendedLayout = UIRectEdgeNone;

      

and the search bar has a visual format applied like V:|-0-searchBar-|

.

The search bar is displayed in the status bar, for example, enter image description here as expected.

I haven't been able to find a solution to get the search bar to start at the bottom of the status bar. How can I do that?

EDIT: I looked at the top layout option, but I have an xib for my custom view controller. No top layout guide. How can I support this setting? I would like to avoid checking the system version. ib screenshot

+3


source to share


2 answers


I was able to programmatically access the master guide by following this answer . I was using XIB for my custom class and therefore could not access topLayoutGuide

through the GUI like below.

ib screenshot Instead, topLayoutGuide

can be accessed via [self topLayoutGuide]

, where self is UIViewController

. Documentation link



if ([self respondsToSelector:@selector(topLayoutGuide)]) {
    id topGuide = [self topLayoutGuide];
    NSDictionaryOfVariableBindings(topGuide ...

      

0


source


You need to use topLayoutGuide

.



Apple has a great guide on this issue: https://developer.apple.com/library/ios/qa/qa1797/_index.html

+1


source







All Articles