【发布时间】:2012-03-15 12:26:55
【问题描述】:
我正在尝试在我的应用中画线。首先,我将绘图窗口大小设置为我的视图大小。完成绘图后,我想调整 UIImageView 的大小,以便绘图周围没有空格。有没有像 UILabel 中的 sizeToFit 一样自动调整 UIImageView 大小的选项?
UIGraphicsBeginImageContext(self.vwDesktop.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, self.vwDesktop.frame.size.width, self.vwDesktop.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 10.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextFlush(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
drawImage.userInteractionEnabled = YES;
【问题讨论】:
标签: objective-c ios xcode uiview uiimageview