【发布时间】:2016-01-27 06:01:40
【问题描述】:
有什么方法可以改变 UIBezierPath 的绘图形状,当用户拖动手指时,它就像一条线,但我想要星形、圆形和其他有什么方法可以实现。
这是我的 UIBezierPath 代码:
-(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
touchPoint = [touch locationInView:self];
if (!CGPointEqualToPoint(startingPoint, CGPointZero))
{
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(touchPoint.x,touchPoint.y)];
[path addLineToPoint:CGPointMake(startingPoint.x,startingPoint.y)];
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = [path CGPath];
shapeLayer.strokeColor = [single.arrColor[single.i] CGColor];
if([UIDevice currentDevice].userInterfaceIdiom ==UIUserInterfaceIdiomPad)
{
shapeLayer.lineWidth = 7.0;
}
else
{
shapeLayer.lineWidth = 5.0;
}
shapeLayer.fillColor = [[UIColor redColor] CGColor];
[self.layer addSublayer:shapeLayer];
[clearBeizer addObject:shapeLayer];
}
startingPoint=touchPoint;
// [arrLayer addObject:shapeLayer];
NSLog(@"Touch moving point =x : %f Touch moving point =y : %f", touchPoint.x, touchPoint.y);
}
【问题讨论】:
-
好的,我会看到兄弟@HarvantS。
-
@HarvantS。我已经编辑了我的问题,请检查它,只有我需要更改结构,我是绘图应用程序的新手,如果可能的话我需要更多参考,请告诉我我会做的。
-
@HarvantS。在这里发布您的答案,因为我需要解释它是如何发生的,我是绘图应用程序的新手,所以请帮助我
-
是的,你可以这样做。您需要有自定义形状的图标。
标签: ios objective-c calayer uibezierpath