ios导航栏适配

时间:2021-08-08 05:26:03

我们做屏幕导航栏横竖屏适配的时候,会发现top的值多少都有一点的偏移,加了背景色之后从0开始,不加背景色从64开始,解决方法
self.extendedLayoutIncludesOpaqueBars = NO;
self.edgesForExtendedLayout = UIRectEdgeBottom | UIRectEdgeLeft | UIRectEdgeRight;

或者:

self.edgesForExtendedLayout = UIRectEdgeNone;

//设置tabbar和导航栏格式

self.tabBar.tintColor = [UIColor colorWithRed:254/255.0 green:202/255.0 blue:11/255.0 alpha:1];

[[UITabBar appearance] setShadowImage:[[UIImage alloc]init]];

[[UITabBar appearance] setBackgroundImage:[UIImage imageWithColor:[UIColor whiteColor]]];

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageWithColor:[UIColor whiteColor]] forBarMetrics:UIBarMetricsDefault];

[[UINavigationBar appearance] setShadowImage:[UIImage imageWithColor:[UIColor whiteColor]]];