我已经对UIImageView进行了子类化,并试图覆盖drawRect,这样我就可以使用Quartz 2D在图像的顶部进行绘制.我知道这是一个愚蠢的新手问题,但我不知道我做错了什么.以下是界面:
#import <UIKit/UIKit.h>
@interface UIImageViewCustom : UIImageView {
}
- (void)drawRect:(CGRect)rect;
@end
以及实施:
#import "UIImageViewCustom.h"
@implementation UIImageViewCustom
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
}
return self;
}
- (void)drawRect:(CGRect)rect {
// do stuff
}
- (void)dealloc {
[super dealloc];
}
@end
我将断点设置为drawRect
,但它从未命中,这让我觉得它从未被调用过.视图首次加载时不应该调用它吗?我是否错误地覆盖了它?