zoukankan      html  css  js  c++  java
  • iOS 15 新特性适配

    1、导航栏的性能做了优化,默认情况下,如果导航栏与视图没有折叠,导航栏的背景透明,如果系统检测到有重叠的话,会变成毛玻璃的效果

    if (@available(iOS 13.0, *)) {
            UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
            [appearance setShadowImage:[[UIImage alloc] init]];
            [appearance setBackgroundColor:TAD_THM.navigationBackgroundColor];
            // 隐藏分割线 设置一个透明或者纯色的图片 设置nil 或者 [UIImage new]无效
            [appearance setBackgroundImage:[UIImage zt_imageWithPureColor:[UIColor whiteColor]]];
            [appearance setShadowImage:[UIImage zt_imageWithPureColor:[UIColor whiteColor]]];
            [[UINavigationBar appearance] setScrollEdgeAppearance: appearance];
    }
    

    颜色转图片

    + (UIImage *)zt_imageWithPureColor:(UIColor *)color {
        UIGraphicsBeginImageContextWithOptions(CGSizeMake(3, 3), NO, [UIScreen mainScreen].scale);
        UIBezierPath* p = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 3, 3)];
        [color setFill];
        [p fill];
        UIImage* img = UIGraphicsGetImageFromCurrentImageContext();
        return img;
    }
    + (UIImage *)zt_imageWithPureColor:(UIColor *)color size:(CGSize )size{
        UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale);
        UIBezierPath* p = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, size.width, size.height)];
        [color setFill];
        [p fill];
        UIImage* img = UIGraphicsGetImageFromCurrentImageContext();
        return img;
    }
    

    2、UITableView新增了一条新属性:sectionHeaderTopPadding, 默认会给每一个section header 增加一个高度,当我们使用 UITableViewStylePlain 初始化UITableView的时候,能发现sectionHeader增高了22px。解决办法就是手动去除这个高度

    if (@available(iOS 15.0, *)) {
        table.sectionHeaderTopPadding = 0;
    }
    

    3、UIImageWriteToSavedPhotosAlbum存储图片之后的回调不再返回图片了,会返回nil,如果在回调方法里面操作image有可能会直接Crash,目前的解决办法声明一个全局image去记录,后面再去操作

    self.image = image;
    UIImageWriteToSavedPhotosAlbum(image,self,@selector(image:didFinishSavingWithError:contextInfo:), NULL);
                
    - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
        // self.image doing...
    }




  • 相关阅读:
    【教程】模拟登陆百度之Java代码版
    Redis错误配置详解
    Redis内存存储结构分析
    Notepad++安装插件
    hadoop2.x 常用端口及定义方法
    微信订阅号可以开通微信支付吗?
    CDH 的Cloudera Manager免费与收费版的对比表
    Hadoop调度框架
    再谈spark部署搭建和企业级项目接轨的入门经验(博主推荐)
    Hive环境的安装部署(完美安装)(集群内或集群外都适用)(含卸载自带mysql安装指定版本)
  • 原文地址:https://www.cnblogs.com/-ios/p/15338922.html
Copyright © 2011-2022 走看看