iOS нарисует изображение (увеличит зелье) и сохранит
Я хочу создать приложение в iOS с приложением для редактирования изображений со следующими концепциями. Когда я щелкаю позицию на изображении, соответствующая позиция должна увеличиваться, и если я рисую на ней круг, она будет сохранена в точное положение при закрытой позиции масштабирования.
, Я сделал что-то с помощью CAShapelayer, когда я нажимаю на изображение, программно нарисую круг по приведенному ниже коду
, Теперь работа, когда я нажимаю на изображение, отлично нарисует круг
, Но я хочу, чтобы, когда я нажимал на изображение, оно создавало небольшой круговой вид и заполнялось щелчковым зельем изображения (увеличенное изображение).
, Когда я нажимаю на это увеличенное изображение, необходимо создать круг и закрыть масштаб изображения, а также круг должен отображаться на обычном изображении.
, Доступна ли какая-либо библиотека? Я надеюсь, что кто-то поможет это сделать.
(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
}
}