iOS15出现的问题及其适配

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

if (@available(iOS 15.0, *)) {
    UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
    [appearance setShadowImage:[[UIImage alloc] init]];
    [appearance setBackgroundColor:TAD_THM.navigationBackgroundColor];
    [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;
}

UINavigationBar默认是透明的,当滑动时会逐渐变为模糊效果,我们可以改变scrollEdgeAppearance属性直接变为模糊效果。

if (@available(iOS 15.0, *)){
    UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
    appearance.backgroundEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleRegular];
    navBar.scrollEdgeAppearance = appearance;
}

2、iOS15中UITableView新增了一个属性sectionHeaderTopPadding, 默认会给每一个section header 增加一个高度,当我们使用 UITableViewStylePlain 初始化UITableView的时候,能发现sectionHeader增高了22px,头部会出现留白的情况。

 解决办法:

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

全局适配设置

if (@available(iOS 15.0, *)) {
    
    [UITableView appearance].sectionHeaderTopPadding = CGFLOAT_MIN;
}

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{
   

}

 

 

 

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值