iOS 版本纪录

1.layer.mask不生效

  • iOS14.0之前:
UIImage * maskImage = [[UIImage imageNamed:@"xxx.png"] stretchableImageWithLeftCapWidth:stretch topCapHeight:stretch];
UIImageView *maskImageView = [[UIImageView alloc]  initWithImage:maskImage]; 
maskImageView.userInteractionEnabled = YES; 
maskImageView.frame = imageView.bounds; 
imageView.layer.mask = maskImageView.layer
  • iOS 14.0 之后
    if (@available(iOS 14.0,*))
    {
        CALayer *maskLayer = [CALayer layer];
        maskLayer.frame = CGRectMake(0, 0, imageView.bounds.size.width, imageView.bounds.size.height);
        
        [maskLayer setContents:(id)maskImage.CGImage];
        [maskLayer setContentsScale:maskImage.scale];
        [maskLayer setContentsCenter:CGRectMake(((maskImage.size.width/2) - 1)/maskImage.size.width, ((maskImage.size.height/1.5) - 1)/maskImage.size.height, 1 / maskImage.size.width, 1 / maskImage.size.height)];
        
        imageView.layer.mask = maskLayer;
        imageView.layer.masksToBounds = YES;
    }

2.UIPageControl设置currentPageImage/pageImage崩溃

  • iOS 14.0之前
[_pageControl setValue:[UIImage imageNamed:@"this_page"] forKeyPath:@"currentPageImage"];
[_pageControl setValue:[UIImage imageNamed:@"that_page"] forKeyPath:@"pageImage"];
  • iOS 14.0之后
if (@available(iOS 14.0, *))
{
 _pageControl.backgroundStyle = UIPageControlBackgroundStyleMinimal;
_pageControl.allowsContinuousInteraction = false;
_pageControl.preferredIndicatorImage = [UIImage imageNamed:@"this_page"];
                    // 目前发现只能通过这样的方式去设置当前选中的图片颜色
_pageControl.currentPageIndicatorTintColor = [UIColor redColor];
[_pageControl setIndicatorImage:[UIImage imageNamed:@"that_page"] forPage:0];
} 

你可能感兴趣的:(iOS 版本纪录)