Tag: uibezierpath

沿着弯曲的UIBezierPath绘制渐变

在应用程序中,我绘制了一个弯曲的UIBezierPath和一个MKOverlayPathView类来显示航线。 这是我正在使用的代码: – (UIBezierPath *)pathForOverlayForMapRect:(MKMapRect)mapRect { … bla bla bla … UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:s]; [path addQuadCurveToPoint:e controlPoint:cp1]; [path addLineToPoint:e2]; [path addQuadCurveToPoint:s2 controlPoint:cp2]; [path closePath]; return path; } – (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context{ self.mapRect = mapRect; CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0); CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 1.0); CGContextSetLineWidth(context, mapRect.size.height/700); CGContextSetLineJoin(context, kCGLineJoinRound); CGContextSetLineCap(context, kCGLineCapRound); CGContextAddPath(context, […]

检测是否绘制path是xcode中的一个圆/矩形

我想为绘图应用程序实现自动完成function。 一旦绘制了自由手对象,我想检测对象的types(圆形/矩形/三angular形),并根据结果绘制出相应的对象。 我已经读了一些关于OpenCV,但是我需要实时将用户绘图转换成图像。 我logging触摸绘制/追踪的点的数量,并生成相应path的UIBeizerPath 。 我如何去检测形状types?

如何创build几个沿path/ BezierCurve的UIButton?

我如何沿path创build对象/ BezierCurve? 换句话说,我怎样才能创build几个UIButtons沿给定的path,给定的时间间隔沿同一path? 我看到了几十个关于移动物体的问题。 但是我需要一个解决scheme来实际创build它们。 我想沿着path走,并为每个X点/距离创build一个对象。 喜欢这个: ….@….@….@….@…. 在这种情况下,每4点获得一个位置,并在那里创build一个UIButton。

触摸移动在CAShapeLayer绘图慢/ laggy

正如在先前的StackOverflow问题中向我推荐的那样,我试图改进我的绘图方法,让我的用户在UIView中绘制线条/点。 我现在试图绘制使用CAShapeLayer而不是dispatch_async。 然而,这一切都正常工作,但是,在触摸移动的同时不断移动到CAShapeLayer中变得缓慢,path滞后,而我的旧的(效率低下的我被告知)代码工作得非常stream畅和快速。 你可以看到我的旧代码注释如下。 有什么办法来改善我想要做的事情吗? 也许我正在过度看待一些事情。 我会很感激提供的任何帮助。 码: @property (nonatomic, assign) NSInteger center; @property (nonatomic, strong) CAShapeLayer *drawLayer; @property (nonatomic, strong) UIBezierPath *drawPath; @property (nonatomic, strong) UIView *drawView; @property (nonatomic, strong) UIImageView *drawingImageView; CGPoint points[4]; – (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; self.center = 0; points[0] = [touch locationInView:self.drawView]; if (!self.drawLayer) […]

如何检查触摸点是否在UIBezierPath(iOS)上

我怎么知道一个触摸点(touchesBegan)是否在隐藏的UIBezierPath上?

如何在iOS中简化一个复杂的UIBezierPath多边形

问题: 我有一个用户生成的多边形(通过在屏幕上注册用户的触摸),可以是简单的或复杂的(复杂的手段具有未知数量的交点),我想有一个简单的多边形产生于原多边形相同的点,就像轮廓或轮廓,如果你愿意。 可能的解决scheme: 我已经find了这个 ,但它是一个JavaScript解决scheme, 这是一个完美的例子,我需要什么,但在ActionScript! 我不需要path本身,这些点就足够了。 你会如何解决这个问题? 更新: 当我进一步观察的时候,我看到有几个人认为解决scheme在点上使用凸包algorithm,但是凸包不是这里的答案,因为如果我是正确的,结果如下:

如何在UIView中绘制贝塞尔曲线

我需要在UIView制作曲线,如下图所示。 我必须使用UIBezierPath 。 请帮我解决这个问题。 我也想知道如何从水平轴上翻转曲线,这样我的弧顶部和底部的底部。

IOS:animation从一条线到贝塞尔曲线的变换

我想创build一条弯曲成贝塞尔曲线(从“_”到“n”)的直线,有没有一个库可以帮助我做到这一点? 我知道如何用UIBezierPath绘制一条贝塞尔曲线,我可以快速重绘,并逐步进行转换,但是如果已经有这样的事情,那就太酷了:-)

对使用UIBezierPath创build的弧应用渐变颜色

我想创build一个弧形的进度条。 进度条的颜色必须根据值进行更改。 我使用UIBezierPath bezierPathWithArcCenter创build了一个弧。 我使用了下面的代码: – (void)viewDidLoad { [super viewDidLoad]; int radius = 100; CAShapeLayer *arc = [CAShapeLayer layer]; arc.path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(100, 50) radius:radius startAngle:60.0 endAngle:0.0 clockwise:YES].CGPath; arc.position = CGPointMake(CGRectGetMidX(self.view.frame)-radius, CGRectGetMidY(self.view.frame)-radius); arc.fillColor = [UIColor clearColor].CGColor; arc.strokeColor = [UIColor purpleColor].CGColor; arc.lineWidth = 15; [self.view.layer addSublayer:arc]; CABasicAnimation *drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; drawAnimation.duration = 5.0; // "animate […]

多点触控追踪问题

我正在使用多点触控书写,所以基本上我正在做的是,我手写支持,因为通常,它的用户权限,我跟着这个链接如何忽略多点触控顺序中的某些UITouch点 所以,我正在做的是,我正在touchesBegan中跟踪一个touch对象,并且只在touchesMoved中使用它。一切工作正常,但是在写一些时候,我得到了这一行 在上图中,您可以看到用手触摸屏幕时突然出现的粗线 这是代码 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"Touches began"); UITouch* topmostTouch = self.trackingTouch; for (UITouch *touch in touches) { bufIdx = 0; isFirstTouchPoint = YES; ctr = 0; pts[0] = [touch locationInView:self]; if(!topmostTouch || [topmostTouch locationInView:self].y > pts[0].y) { topmostTouch = touch; //touchStartPoint1 = pts[0]; } else { pts[0] = pts[3]; } } […]