我有一个UIImageView在我的IB和我创建的UIImageView的子类有一个方法的drawRect:drawRect中没有得到要求的UIImageView
@implementation UIImageViewLine
- (void)drawRect:(CGRect)rect
{
NSLog(@"CALLED");
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
CGContextSetLineWidth(context, 1.0f);
CGContextMoveToPoint(context, 0, 0);
CGContextAddLineToPoint(context, self.frame.size.width, self.frame.size.height);
CGContextStrokePath(context);
}
@end
我已经改变了类的UIImageView的这个子类,但是的drawRect永远不会被调用。任何想法为什么?
为什么子类的UIImageView不UIView的? – 2012-02-22 23:56:40
舒服,所以我必须继承一个UIView而不是UIImageView的?如果我想在UIImageView上画一条线,该怎么办? – adit 2012-02-23 00:10:44
你可以借鉴的UIImage并使用的UIImageView显示图像 – 2012-02-23 01:27:03