iOS14系统YBImageBrowser显示图片黑屏问题
2022-06-24 本文已影响0人
朋友一生
YYAnimatedImageView.
出现原因:
iOS 14系统调⽤⽅法- (void)displayLayer:(CALayer *)layer,YYAnimatedImageView没有正确处理
解决⽅法:
重写YYAnimatedImageView.m 的中的displayLayer⽅法⼤概在529 ⾏
方法一
if(_curFrame) {
layer.contents= (__bridgeid)_curFrame.CGImage;
}else{
// If we have no animation frames, call super implementation. iOS 14+ UIImageView use this delegate method for rendering.
if([UIImageViewinstancesRespondToSelector:@selector(displayLayer:)]) {
[superdisplayLayer:layer];
}
}
方法二
-(void)displayLayer:(CALayer*)layer{
UIImage*currentFrame=_curFrame;
if(!currentFrame){
currentFrame=self.image;
}
if(currentFrame){
layer.contentsScale=currentFrame.scale;
layer.contents=(__bridge id)currentFrame.CGImage;
}
}