Я пытаюсь разработать приложение для рисования, которое позволяет пользователю рисовать / рисовать поверх изображения, выбирая кисти разного цвета. Я пытался реализовать это путем создания подкласса uiimageview и переопределить следующие методы:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
lastPoint = [touch locationInView:self];
// lastPoint.y -=20;// only if signature goes bottom of the screen
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self];
// currentPoint.y -=20; // only if signature goes bottom of the screen
UIGraphicsBeginImageContext(self.frame.size);
CGContextRef currentContext = UIGraphicsGetCurrentContext();
[self.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
CGContextSetLineCap(currentContext, kCGLineCapRound);
CGContextSetLineWidth(currentContext, 15.0);
CGContextSetRGBStrokeColor(currentContext, 1.0, 0.0, 0.0, 1.0);
CGContextBeginPath(currentContext);
CGContextMoveToPoint(currentContext, lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(currentContext, currentPoint.x, currentPoint.y);
CGContextStrokePath(currentContext);
self.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
}
Но проблема здесь в том, что, если пользователь рисует за границей изображения, то цвет скрывает границу. Мне нужно сделать границу видимой, даже если пользователь рисует и за границей. Это возможно сделатьили мне нужно идти вперед с любыми методами openGL. Пожалуйста, поделитесь своими комментариями ..
Заранее спасибо ..