edgesForExtendedLayout

来源:互联网 发布:outdoorvoices淘宝 编辑:程序博客网 时间:2024/06/06 00:39

适应 navigationBa

1 @property(nonatomic,assign) UIRectEdge edgesForExtendedLayout NS_AVAILABLE_IOS(7_0); // Defaults to UIRectEdgeAll2  @property(nonatomic,assign) BOOL extendedLayoutIncludesOpaqueBars NS_AVAILABLE_IOS(7_0); // Defaults to NO, but bars are translucent by default on 7_0.  3  @property(nonatomic,assign) BOOL automaticallyAdjustsScrollViewInsets NS_AVAILABLE_IOS(7_0); // Defaults to YES

属性edgesForExtendedLayout,意思大概是边缘向四周展开
edgesForExtendedLayout 值是结构体,默认值是 UIRectEdgeAll,
也就是说,当一个控制器要往父控制器添加的时候,上下左右填充满整个屏幕
UIViewController添加到uiNavController上时,uiviewcontroller的y值 == 状态栏的的y这时候设置self.edgesForExtendedLayout = UIRectEdgeNone;
uiviewcontroller的y值 == 导航栏y + 导航栏height
这种情况还可以设置,导航栏的bar的透明度属性translucent为no
self.navigationController.navigationBar.translucent = NO;
translucent属性在ios6之前默认为no,而在ios7下的导航栏默认却是半透明的,为yes,所以该属性不会占据空间

UITableViewController添加到UITabBarController上时,UITableViewController的底部一部分cell会被TabBar挡住这时候设置

self.edgesForExtendedLayout = UIRectEdgeNone;

TabBar的y值 == CGRectGetMaxY(UITableViewController)
self.extendedLayoutIncludesOpaqueBars = YES;
意思展开包括状态栏
self.automaticallyAdjustsScrollViewInsets = YES;
当设计到scrollView、tableview时,在设置完数据的时候,内部会改变contentInsets的top值为64

group样式的tableView在有导航栏的控制器下,第0组的头部会多出一部分高度h原因是 ios7下group样式的tabelView的第0组第0个cell,在tableview中的y值为35!!!
并且在设置完cell数据之后,系统默认会执行self.automaticallyAdjustsScrollViewInsets = YES;
也就是tableview的contentInset.top = 64;
所以 第0组第0行cell的y值 = 64 + 35.

要达到第0组第0行cell的y值 = 导航栏底部 的效果
就要在cell设置数据之前,
tableView.contentInset = UIEdgeInsetsMake(- 35, 0, 0, 0);
这样在cell在设置完数据后,系统内部改变top值增加64,就恰好达到效果。
若要达到每个group头部等高效果,    
tableView.sectionHeaderHeight = cellSectionHeight;
tableView.sectionFooterHeight = 0;
tableView.contentInset = UIEdgeInsetsMake(cellSectionHeight - 35, 0, 0, 0);

网址:http://www.cnblogs.com/wangxiaofeinin/p/3532831.html?utm_source=tuicool&utm_medium=referral

0 0