【发布时间】:2012-10-22 09:28:45
【问题描述】:
如何在 UIImageView 上画一条线?我正在使用 UIImageView 子类,它不支持drawRect: 方法。我想在图像视图上画一条线。我怎样才能做到这一点?请帮我。我使用下面的代码画线。
- (void)drawRect:(CGRect)rect {
CGContextRef c = UIGraphicsGetCurrentContext();
CGFloat red[4] = {1.0f, 0.0f, 0.0f, 1.0f};
CGContextSetStrokeColor(c, red);
CGContextBeginPath(c);
CGContextMoveToPoint(c, 5.0f, 5.0f);
CGContextAddLineToPoint(c, 50.0f, 50.0f);
CGContextStrokePath(c);
}
【问题讨论】:
-
为什么要在图像视图上绘图?你也可以在 UIImage 上画线!!!
-
我想裁剪图像,以便用户可以单击图像画线。
标签: iphone ios uiimageview