降级xcode12后,编译运行App发现大片大片的图片加载不进去,包含weex的图片和YYAnimateView的图片都有问题。
通过一番钻研之后,发现是iOS 14下UIKit对 displayLayer:
的解决机制有所变动。displayLayer:
是CALayerDelegate
的代理办法。在iOS 14之前,UIKit在调用这个办法之前就会去渲染UIImageView.image
。
而在iOS 14,UIKit则是先去调用代理办法,如果你实现了displayLayer:
这个办法,那么UIKit就不会再去渲染了。
如果改成上面这样就能够失常加载了:
- (void)displayLayer:(CALayer *)layer { UIImage *currentFrame = _curFrame; if (currentFrame) { layer.contentsScale = currentFrame.scale; layer.contents = (__bridge id)currentFrame.CGImage; } else { // If we have no animation frames, call super implementation. iOS 14+ UIImageView use this delegate method for rendering. if ([UIImageView instancesRespondToSelector:@selector(displayLayer:)]) { [super displayLayer:layer]; } }// if (_curFrame) {// layer.contents = (__bridge id)_curFrame.CGImage;// }}
参考:
- https://github.com/apache/inc...
- https://github.com/ibireme/YY...
- https://github.com/SDWebImage...
原地址:https://y500.me/2020/09/29/im...