NNikN
NNikN

Reputation: 3850

UINavigationBar without UINavigationController from Interface Builder

I am trying to add UINavigationBar from Interface Builder (not storyBoard).

But, the height remains as 44.

There is one post , which has a answer but thats through code. UINavigationBar without UINavigationController

I did the same but from Interface builder But did not find working. Interface builder and simulator Screen shots are attached with this email. Also, I did add the following method in the Controller.

So, Is it possible from Interface builder?

- (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar
{
    return UIBarPositionTopAttached;
}

enter image description here

enter image description here

Upvotes: 1

Views: 451

Answers (1)

kabiroberai
kabiroberai

Reputation: 2913

Although it may be counter-intuitive, you need to have a constraint with the value of 20 from the top of the view (The constraint should say Top Space to: Top Layout Guide). In the end it should look something like this in interface builder, but during runtime, the navigation bar will add 20 points (or pixels I'm not sure) to the top, making it stretch to the top of the screen.

UINavigationBar in Interface Builder

Upvotes: 1

Related Questions