WXLayer文件修改以下代碼即可:
- (void)display
{
if(@available(iOS 14.0, *)) {
[super display];
}
[self.wx_component _willDisplayLayer:self];
}
PS:我是暫時(shí)直接改的pod文件測試,建議不要這么改撵渡,可以寫個(gè)category交換方法更好吧。
話說我新建了一個(gè)category這個(gè)報(bào)錯(cuò)是為啥呢充岛?怎么解決盹憎?
Embedded添加WeexSDK庫即可。
新建category瘾境;
.h文件
//
// WXLayer+Extension.h
// HaiDiLao
//
// Created by 彭思 on 2020/11/23.
// Copyright ? 2020 haidilao. All rights reserved.
//
#import "WXLayer.h"
#import "WXDefine.h"
#import "WXComponent.h"
#import "WXComponent_internal.h"
NS_ASSUME_NONNULL_BEGIN
@interface WXLayer (Extension)
@end
NS_ASSUME_NONNULL_END
.m文件:
//
// WXLayer+Extension.m
// HaiDiLao
//
// Created by 彭思 on 2020/11/23.
// Copyright ? 2020 haidilao. All rights reserved.
//
#import "WXLayer+Extension.h"
#import <objc/runtime.h>
@implementation WXLayer (Extension)
+(void)load{
/** 獲取原始setBackgroundColor方法 */
Method originalM = class_getInstanceMethod([self class], @selector(display));
/** 獲取自定義的pb_setBackgroundColor方法 */
Method exchangeM = class_getInstanceMethod([self class], @selector(newDishplay));
/** 交換方法 */
method_exchangeImplementations(originalM, exchangeM);
}
/** 自定義的方法 */
-(void)newDishplay{
if(@available(iOS 14.0, *)) {
[super display];
}
[self.wx_component _willDisplayLayer:self];
}
@end