Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

昨天反馈你的图片不显示的问题我找到了 是iOS14以后的系统 #24

Open
love865122909 opened this issue Nov 4, 2020 · 2 comments

Comments

@love865122909
Copy link

原因YYAnimatedImageView不显示图片
在YYAnimatedImageView类里加入

  • (void)load {
    // 获取系统的对象方法
    Method displayLayerMethod = class_getInstanceMethod(self, @selector(displayLayer:));

    // 获取自己定义的对象方法
    Method displayLayerNewMethod = class_getInstanceMethod(self, @selector(displayLayerNew:));

    // 方法交换
    method_exchangeImplementations(displayLayerMethod, displayLayerNewMethod);
    }

  • (void)displayLayerNew:(CALayer *)layer {

    Ivar imgIvar = class_getInstanceVariable([self class], "_curFrame");
    UIImage *img = object_getIvar(self, imgIvar);
    if (img) {
    layer.contents = (__bridge id)img.CGImage;
    } else {
    if (@available(iOS 14.0, *)) {
    [super displayLayer:layer];
    }
    }

@love865122909
Copy link
Author

就可以显示了

@CoderMikeHe
Copy link
Owner

ok 感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants