iOS 7 UINavigationBar - UIView layout issue

你说的曾经没有我的故事 提交于 2019-11-30 01:41:13
null

Try navigationBar.translucent = NO;

It is YES by default.

From the UINavigationBar documentation:

New behavior on iOS 7. Default is YES. You may force an opaque background by setting the property to NO. If the navigation bar has a custom background image, the default is inferred from the alpha values of the image—YES if it has any pixel with alpha < 1.0 If you send setTranslucent:YES to a bar with an opaque custom background image it will apply a system opacity less than 1.0 to the image. If you send setTranslucent:NO to a bar with a translucent custom background image it will provide an opaque background for the image using the bar's barTintColor if defined, or black for UIBarStyleBlack or white for UIBarStyleDefault if barTintColor is nil.

Add this line to your 'view will appear' method (if it is not there, add it by typing:

- (void)viewWillAppear:(BOOL)animated
{

    [super viewWillAppear:animate];

}

)

Then, at the bottom of viewWillAppear, underneath the [self viewWillAppear:] line, add this code:

if([self respondsToSelector:@selector(edgesForExtendedLayout)])
    [self setEdgesForExtendedLayout:UIRectEdgeBottom];

This will make the top bar (nav bar) go opaque. In iOS 7, Obj-C now responds differently to whether or not the nav bar has been set to opaque, and this is a good way to gaurentee it works in both iOS 6 and 7 (there are some problems doing just:

navigationBar.translucent = NO;

)

Hope this helps, I had the same problem when I converted an app to iOS 7 and it took ages to find a solution!

In IOS7 UINavigationBar style is Translucent by default so it will hide view Content Underneath, to show your content Under UInavigation bar write down following snippet in given method.

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    if([self respondsToSelector:@selector(edgesForExtendedLayout)])
        [self setEdgesForExtendedLayout:UIRectEdgeBottom];
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!