Ios 调整使用CoreGraphics绘制的图像大小
我已经跟着问题走了,现在我的触摸位置上有了圆圈 现在我想做一个收缩手势,用圆圈调整视图的大小(比如在Photo.app中缩放照片),用CoreGraphics对象可以实现这种行为吗 以下是我的圆形绘图代码:Ios 调整使用CoreGraphics绘制的图像大小,ios,core-graphics,Ios,Core Graphics,我已经跟着问题走了,现在我的触摸位置上有了圆圈 现在我想做一个收缩手势,用圆圈调整视图的大小(比如在Photo.app中缩放照片),用CoreGraphics对象可以实现这种行为吗 以下是我的圆形绘图代码: CGContextRef ctx= UIGraphicsGetCurrentContext(); CGContextSaveGState(ctx); CGContextSetLineWidth(ctx,5); CGContextSetRGBStrokeColor(ctx,0.8,0.8,
CGContextRef ctx= UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
CGContextSetLineWidth(ctx,5);
CGContextSetRGBStrokeColor(ctx,0.8,0.8,0.8,1.0);
CGContextAddArc(ctx,20,40,30,0.0,M_PI*2,YES);
CGContextStrokePath(ctx);
1) 首先,您需要设置视图的层次结构(通过编程或通过Interface Builder)
例如:
UIViewController
UIView
UISrollView
UIView
UIImageView
2) 设置自动布局。()
3) 画你的圆圈。此示例适用于IB设置方法
- (UIImage *)drawCircle {
CGContextRef ctx= UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
CGContextSetLineWidth(ctx,5);
CGContextSetRGBStrokeColor(ctx,0.8,0.8,0.8,1.0);
CGContextAddArc(ctx,20,40,30,0.0,M_PI*2,YES);
CGContextStrokePath(ctx);
return UIGraphicsGetImageFromCurrentImageContext()
}
- (void)viewDidLoad {
[super viewDidLoad];
self.imageView.image = [self drawCircle];
}
4) 设置夹持手势: