画一个像快捷键键盘iOS的尾巴

时间:2016-02-15 11:16:06

标签: ios drawing uigraphicscontext

我想制作自定义键盘。我完成了所有功能,但无法在我的应用中实现滑动功能。当我在键盘上滑动时,字母输入正确但线条(绘图)无法完美绘制。我无法删除旧的路径。请帮助。我想要这种类型的滑动。

enter image description here

我写这段代码

- (void)touchesBegan: (NSSet *)touches withEvent: (UIEvent *)event {
CGPoint location = [[touches anyObject] locationInView:self];
myPath=nil;
[_myPathArray removeAllObjects];

myPath=[[UIBezierPath alloc]init];
myPath.lineCapStyle=kCGLineCapRound;
myPath.lineWidth=5.0;

_brushPattern=[UIColor redColor];

_myArray=[[NSMutableArray alloc]init];

UITouch *mytouch=[[touches allObjects] objectAtIndex:0];
[myPath moveToPoint:[mytouch locationInView:self]];}

-(void)touchesMoved:(NSSet *)touches withEvent: (UIEvent *)event {
CGPoint location = [[touches anyObject] locationInView:self];
[myPath addLineToPoint:location];
shapeLayer.path = myPath.CGPath;
shapeLayer.strokeColor = _brushPattern.CGColor;
shapeLayer.lineWidth = 3.0;
shapeLayer.fillColor = [[UIColor clearColor] CGColor];
[self.layer addSublayer:shapeLayer];
[self setNeedsDisplay];}

此代码给出了此结果。但我想在一些路径绘制之后删除路径..比如 swype键盘enter image description here

0 个答案:

没有答案