izik461
izik461

Reputation: 1173

UIViewController from XIB not resizing to UINavigationBar

I've created MyViewController in separate xib and pushed it to navigation stack. It is loaded properly and resizing, but hides below the displayed navigation bar (green button hidden): enter image description here In the xib I've set all options of top bar to inferred:

enter image description here

How can I solve it? Of course I can manually add spacing in the xib, but it's just not the right way.

EDIT: In xib's attributes I don't see extend under Top Bar tick, since in xib I have created UIView with file owner set to MyViewController.

enter image description here

enter image description here

Upvotes: 0

Views: 182

Answers (3)

AtaerCaner
AtaerCaner

Reputation: 712

It is because of translucent. You should do this.

self.navigationController?.navigationBar.isTranslucent = false

And you'll see it works. When the navigation bar is not translucent, xib can't locate behind the navigation bar to show what it has.

Upvotes: 2

Umair Afzal
Umair Afzal

Reputation: 5039

Select your View in xib and the go to attribute inspector

enter image description here

and select top Bar as shown in screenshot and then design your screen accordingly. It gives you an idea about how much space will your navigation bar take.

Upvotes: 0

izik461
izik461

Reputation: 1173

I've managed with changing edgesForExtendedLayout property programatically in viewDidLoad:

self.edgesForExtendedLayout = UIRectEdgeRight | UIRectEdgeLeft | UIRectEdgeBottom;

With some help from question: How to set UIViewController "extend edges" properties

Upvotes: 0

Related Questions