【发布时间】:2015-08-29 21:30:57
【问题描述】:
我正在按照苹果文档中的建议覆盖 UIView 的 layerClass 方法,如下所示:
+ (Class)layerClass {
return [ViewLayerBase class];
}
在我的 viewLayerBase 自定义类中,我有一个这样实现的 init 方法:
- (id)initWithRect:(CGRect)rect {
if ((self = [super init])) {
NSLog(@"I got called");
}
return self;
}
我的 UIView 子类显然没有调用此方法。鉴于 UIView 的 layer 属性是只读的,我无法做到myView.layer = [ViewLayerBase alloc] initWithRect... 如何让 UIView 实例化我的自定义 CALayer 子类?
【问题讨论】:
标签: ios core-animation