Make Navigation Bar stretch behind status bar in xCode 5 / iOS7

前端 未结 2 1794
借酒劲吻你
借酒劲吻你 2020-12-31 20:10

I have followed the following tutorial to move my navigation bar down so it is not covered by the status bar in xcode 5/ios7:

Status bar and navigation bar issue in

2条回答
  •  旧时难觅i
    2020-12-31 20:33

    You do want to set the barPosition of the UINavigationBar.

    You can do this in code:

    Let your ViewController conform to protocol UINavigationBarDelegate and implement positionBar: metod. (The protocol that you really need is UIBarPositioningDelegate but UINavigationBarDelegate does extend it.)

    @interface SampleViewController () 
    @property (weak, nonatomic) IBOutlet UINavigationBar *navigationBar;
    @end
    
    @implementation SampleViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        _navigationBar.delegate = self;
    }
    
    - (UIBarPosition)positionForBar:(id)bar {
        return UIBarPositionTopAttached;
    }
    @end
    

    OR in Storyboard:

    In the Identity Inspector of UINavigationBar, add a User Defined runtime Attribute with KeyPath = barPosition, Type = Number, and Value = 3:

    Add User Defined Runtime Attribute

提交回复
热议问题