我正在使用paintcodeapp 来绘制我的自定义按钮。我画了两种不同的状态“按下”和“正常”
当按钮处于“按下状态”时,我需要调用 setNeedsDisplay
self.highlighted
然后我在drawRect:
方法中使用分派两个抽奖
我试过:
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self addTarget:self action:@selector(didDetectEvent:) forControlEvents:UIControlEventTouchDown];
[self addTarget:self action:@selector(didDetectEvent:) forControlEvents:UIControlEventTouchUpInside];
[self addTarget:self action:@selector(didDetectEvent:) forControlEvents:UIControlStateNormal];
}
return self;
}
-(void)didDetectEvent:(id)sender {
[self setNeedsDisplay];
}
但它不起作用。有什么建议吗?