研究环境:ios7.1, iphone4
情况1 当UIView , UITableView使用约束时,UINavigationBar 不会遮挡使用了他们;
情况2 当UIView , UITableView 不使用约束时,UINavigationBar 会遮挡使用了他们;
当你采用情况2时,为了避免view被遮挡,一般都会采用以下方法:
// 防止UITableview被UITabbarView遮挡
if (([[[UIDevicecurrentDevice] systemVersion]doubleValue] >= 7.0)) {
self.edgesForExtendedLayout =UIRectEdgeNone;
self.automaticallyAdjustsScrollViewInsets =NO;
}
self.tableView.autoresizingMask =UIViewAutoresizingFlexibleHeight |UIViewAutoresizingFlexibleWidth;
但是,我们需要注意self.edgesForExtendedLayout = UIRectEdgeNone; 和 self.edgesForExtendedLayout = UIRectEdgeAll 的区别,不管UINavigationBar是否透明,或者任何颜色,效果都将如下:
采用self.edgesForExtendedLayout = UIRectEdgeNone; 效果图如下,即,UINavigationBar不遮挡:
采用self.edgesForExtendedLayout = UIRectEdgeAll; 效果图如下,即,UINavigationBar遮挡: