多年不写ios,目前重构项目,发现navBar和tabbar需要注意的点,记录备忘
translucent属性会导致view起始点的变化,默认为透明,和设计图有色差,改成不透明以后,坐标位置有变化,修改如下
[[UINavigationBar appearance] setTranslucent:NO];
self.extendedLayoutIncludesOpaqueBars = YES;
UITabBar类似
[[UITabBar appearance] setTranslucent:NO]; UIEdgeInsets adjustForTabbarInsets = UIEdgeInsetsMake(0, 0, self.tabBarController.tabBar.frame.size.height, 0); self.tableView.contentInset = adjustForTabbarInsets;
在某些viewController内贴view,可能会有位置错误,可以用下面代码试试
self.edgesForExtendedLayout = UIRectEdgeNone;
具体详解,网上找资料