阅读 104

xocde13上打包app的适配方案记录

1.navigationbar变透明

解决方法:

 @implementation** UINavigationController (Extension) /// 更改为颜色 - (void)changeBackgroundColor:(UIColor *)color {     static UIImage *backgroundImage = nil;     static UIImage *shadowImage = nil;     if (!backgroundImage) {         backgroundImage = [LGImage imageWithColor:color];         shadowImage = [LGImage imageWithColor:[UIColor clearColor]];     }          if (@available(iOS 13.0, *)) {          // iOS13 之后用这个         UINavigationBarAppearance *apparance = [[UINavigationBarAppearance alloc] init];         [apparance configureWithOpaqueBackground];         apparance.backgroundColor = color;         [apparance setShadowImage:shadowImage];         self.navigationBar.standardAppearance = apparance;         self.navigationBar.scrollEdgeAppearance = self.navigationBar.standardAppearance;     } else {     // iOS15之后失效         [self.navigationBar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];         [self.navigationBar setShadowImage:shadowImage];     } } /// 更改为图片 - (void)changeBackgroundImage:(UIImage *)image {        static UIImage *shadowImage = nil;     if (!shadowImage) {         shadowImage = [LGImage imageWithColor:[UIColor clearColor]];     }          if (@available(iOS 13.0, *)) {         UINavigationBarAppearance *apparance = [[UINavigationBarAppearance alloc] init];         [apparance configureWithOpaqueBackground];         apparance.backgroundColor = [UIColor clearColor];         [apparance setShadowImage:shadowImage];         self.navigationBar.standardAppearance = apparance;         [self.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];         self.navigationBar.scrollEdgeAppearance = self.navigationBar.standardAppearance;     } else {         [self.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];         [self.navigationBar setShadowImage:shadowImage];     } } @end 复制代码

2.tabbar变透明

 - (void)changeBackgroundColor:(UIColor *)color{     if (@available(iOS 15.0, *)) { //iOS15后添加更改tabbar新类,用这个更改背景色         UITabBarAppearance *appearance = [[UITabBarAppearance alloc] init];         [appearance configureWithOpaqueBackground];         appearance.backgroundColor = color;         self.tabBar.standardAppearance = appearance;         self.tabBar.scrollEdgeAppearance = appearance;     } } 复制代码

3.iphone13 mini顶部安全区域更改需要注意


作者:Rui4u君
链接:https://juejin.cn/post/7019216813397377032


文章分类
后端
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐