setEdgesForExtendedLayout
用于布局的扩展边。
@property(nonatomic,assign) UIRectEdge edgesForExtendedLayout NS_AVAILABLE_IOS(7_0);
// Defaults to UIRectEdgeAll
1.此属性只应用于视图控制器是嵌入在一个容器如UINavigationController。根视图控制器不响应此属性。它的默认值是UIRectEdgeAll。默认的布局将从navigation bar的顶部开始。这就是为什么所有的UI元素都往上漂移了64pt
2.UIRectEdgeAll = UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeBottom |
解决方法1.###
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//在viewWillAppear或viewDidLoad方法中添加以下代码
if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
解决方法2.###
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//在viewWillAppear或viewDidLoad方法中添加以下代码
self.navigationController.navigationBar.translucent = YES;