adi*_*dit 4 iphone objective-c ipad ios
我的IB中有一个UIImageView,我用一个方法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
Run Code Online (Sandbox Code Playgroud)
我已经将UIImageView的类更改为此子类,但是从不调用drawRect.知道为什么吗?