我需要一个自定义层(由新变量和方法扩展)并如下所示。问题是该层不会响应我的方法:
-[CALayer drawHourCircleWithDayLightStart:dayLightEnd:animated:]:无法识别的选择器发送到实例 0x6a6d560**
似乎我的自定义图层没有被视为 HourCircleLayer,而是被视为 CALayer。但我必须在这里改变吗?
我的实现如下所示:
@interface HourCircleLayer : CALayer
@property (strong) UIColor *dayColor; // default yellowColor
@property (strong) UIColor *nightColor; // default blueColor
+ (id)layer;
- (void)drawHourCircleWithDayLightStart:(NSDate *)startDate dayLightEnd:(NSDate *)endDate animated:(BOOL)animated;
@end
@implementation HourCircleLayer
+ (id)layer
{
id layer = [CALayer layer];
[layer setValue:[UIColor yellowColor] forKey:kDayPortionColorKey];
[layer setValue:[UIColor blueColor] forKey:kNightPortionColorKey];
return layer;
}
- (void)drawHourCircleWithDayLightStart:(NSDate *)startDate dayLightEnd:(NSDate *)endDate animated:(BOOL)animated
{
self.withAnimation = animated;
[self setDayLightStart:[self hourAngleForDate:startDate]];
[self setDayLightEnd:[self hourAngleForDate:endDate]];
}
@end