1

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.

Community
  • 1
  • 1
John Kakon
  • 2,491
  • 4
  • 21
  • 28

2 Answers2

1

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

Community
  • 1
  • 1
Shingoo
  • 796
  • 8
  • 26
0

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?

Community
  • 1
  • 1
  • Thank you for your answer, but I don't have this option because I develop for "iOS7 and later". I think there is another way to do it for iOS7, but I don't know how. I tried to add some constraints, but it is imposible for navigation bar inside navigation view. – John Kakon Jun 11 '14 at 10:59