UIBezierPath没有绘制平滑曲线 [英] UIBezierPath not drawing a smooth curve
本文介绍了UIBezierPath没有绘制平滑曲线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用UIBezierPath进行绘图,我已经在触摸事件上编写了代码并且它的工作正常,但是我的曲线并不平滑,当我移动手指并绘制一些曲线时,它们并不平滑。
I am using UIBezierPath for drawing, and I have written the code on touch events and its working fine, but my curves are not smooth, when I am move my finger around and draw some curve, they are not smooth.
- (void)drawRect:(CGRect)rect
{
[[UIColor redColor] setStroke];
for (UIBezierPath *_path in pathArray)
[_path strokeWithBlendMode:kCGBlendModeNormal alpha:1.0];
}
#pragma mark - Touch Methods
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
myPath=[[UIBezierPath alloc]init];
myPath.lineWidth=5;
myPath.lineCapStyle = kCGLineCapRound;
myPath.flatness = 0.0;
UITouch *mytouch=[[touches allObjects] objectAtIndex:0];
[myPath moveToPoint:[mytouch locationInView:self]];
[pathArray addObject:myPath];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *mytouch=[[touches allObjects] objectAtIndex:0];
[myPath addLineToPoint:[mytouch locationInView:self]];
[self setNeedsDisplay];
}
这是图片
在如果你看到字母a和d,你会看到曲线不平滑。我该怎么做才能获得平滑的曲线?
In the above image if you see the letters a and d you will see that the curve is not smooth. What should I do, to get a smooth curve?
推荐答案
只需使用此行即可。它将解决您的问题 myPath.miterLimit = -10;
。
Just use this line. it will solve your problem myPath.miterLimit=-10;
.
如果您需要任何东西,请更改值它需要浮动值
Change the value if you need to any thing it takes float value
这篇关于UIBezierPath没有绘制平滑曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文