以下のコンセプトの画像編集アプリでiOSアプリを作りたいと思っています。関連する位置がズームする必要がある画像上の位置をクリックすると、その上に円を描くと、ズーム位置を閉じたときに正確な位置に保存されます
. 画像をクリックすると、以下のコードでプログラムによって円が描画されます。
. 画像をクリックすると円が完全に描画されるようになりました
. しかし、画像をクリックすると、小さな円の画像ビューが作成され、画像のクリックされた部分(ズーム画像)で塗りつぶされます
. そのズームされた画像ビューをクリックすると、円を作成してズームビューを閉じる必要があり、円は通常の画像に表示する必要があります
. 利用可能なライブラリはありますか? 誰かがそれを手伝ってくれることを願っています。
(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint touch_point = [touch locationInView:self.view];
if ([imgVw pointInside:touch_point withEvent:event])
{
NSLog(@"point inside imageview");
CGPoint point = [touch locationInView:self.view];
NSLog(@"X location: %f", point.x);
NSLog(@"Y Location: %f",point.y);
CAShapeLayer *circleLayer = [CAShapeLayer layer];
// Give the layer the same bounds as your image view
[circleLayer setBounds:CGRectMake(0.0f, 0.0f, [imgVw bounds].size.width,
[imgVw bounds].size.height)];
// Position the circle anywhere you like, but this will center it
// In the parent layer, which will be your image view's root layer
[circleLayer setPosition:CGPointMake([imgVw bounds].size.width/2.0f,
[imgVw bounds].size.height/2.0f)];
// Create a circle path.
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:
CGRectMake(point.x, point.y, 10.0f, 10.0f)];
// Set the path on the layer
[circleLayer setPath:[path CGPath]];
// Set the stroke color
[circleLayer setStrokeColor:[[UIColor redColor] CGColor]];
// Set the stroke line width
[circleLayer setLineWidth:2.0f];
[layerArray addObject:circleLayer]; // will push all layer in to array it will help to re edit like undo operation
[[imgVw layer] addSublayer:circleLayer]; //will add a circle on image
}
}