John Kakon
John Kakon

Reputation: 2541

Move navigation bar in navigation view controller in ios7

I want add 20 points margin to my navigation bar. I need it because I want another background color under status bar as youtube did:

enter image description here

I found

iOS Developer library says: Status bar background appearance provided by the window background, if using UIBarPositionTop.

I found solution for toolbar, but I can't move my navigation bar inside navigation view controller. I just set UIBarPositionTop for my navigation bar, but it changes nothing.

-(UIBarPosition)positionForBar:(id<UIBarPositioning>)bar {
    NSLog(@"position method called");
    return UIBarPositionTop;
}

I still see the gray background of status bar instead of white.

enter image description here

Is it possible to do it with a navigation bar or should I use a view with a toolbar?

(XCode 6, development target 7.0+, sdk 8.0, autolayout)

UPDATE: ANOTHER WAY TO RESOLVE PROBLEM

I read this question and understood, that there is no need to add margin. I added view with background color I need over my navigation bar controller and it resolved my problem.

Upvotes: 1

Views: 1000

Answers (2)

Shingoo
Shingoo

Reputation: 836

When you are adding your UIView to the UIWindow, you should change the UIViews size to not underlap the title bar. How to do this is well documented in this post:

Offset on UIWindow addSubview

Upvotes: 1

obogz_mobile
obogz_mobile

Reputation: 365

I hope i understood correctly, look in size inspector, ios 6/7 deltas. Check this link for an explanation: Interface Builder: What are the UIView's Layout iOS 6/7 Deltas for?

Upvotes: 0

Related Questions