Files
mier_ios/SweetParty/第三方库/YYImage/YYAnimatedImageView+ImageShow.m
2025-08-11 10:43:19 +08:00

44 lines
1.1 KiB
Objective-C
Executable File

//
// YYAnimatedImageView+ImageShow.m
// miliao
//
// Created by 八角_马方圆 on 2021/12/8.
// Copyright © 2021 miliao. All rights reserved.
//
#import "YYAnimatedImageView+ImageShow.h"
#import <objc/message.h>
@implementation YYAnimatedImageView (ImageShow)
+ (void)load{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// 获取系统的方法
Method displayLayerMethod = class_getInstanceMethod(self, @selector(displayLayer:));
// 获取更新的方法
Method displayLayerNewMethod = class_getInstanceMethod(self, @selector(displayLayerNew:));
// 方法交换
method_exchangeImplementations(displayLayerMethod, displayLayerNewMethod);
});
}
- (void)displayLayerNew:(CALayer *)layer{
Ivar imageIvar = class_getInstanceVariable([self class], "_curFrame");
UIImage *image = object_getIvar(self, imageIvar);
if (image) {
layer.contents = (__bridge id)image.CGImage;
}
else{
if (@available(iOS 14.0,*)) {
[super displayLayer:layer];
}
}
}
@end