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

iOS 14 上的图片打开黑屏什么时候可以更新下 #355

Open
yanjixiang opened this issue Jan 25, 2024 · 3 comments
Open

iOS 14 上的图片打开黑屏什么时候可以更新下 #355

yanjixiang opened this issue Jan 25, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@yanjixiang
Copy link

Feature Description

@yanjixiang yanjixiang added the enhancement New feature or request label Jan 25, 2024
@a289459798
Copy link

解决了吗

@fangjinfeng
Copy link

@fangjinfeng
Copy link

  • (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];
    }
    }
    }

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

No branches or pull requests

3 participants