Tag: uibezierpath

使用CAShapeLayer对象与Bezierpath绘制一条线

我正在做一个图像编辑器,可以创build不同形状的对象,如圆形,三angular形和正方形,也可以更新或删除。 所以我用CAShapeLayer来创build形状对象。 现在我也想绘制一个图像,也可以更新或删除线,所以我用bezierpath和CAShapeLayer来创build线,它工作正常。 但现在的问题是,当我想要select任何现有的线可以select任何地方接近线工具,因为CAShapeLayer也设置填充区域,这将是一条从起点到终点的直线。 我的问题是,如何使用CAShapeLayer创build没有填充区域的CAShapeLayer 。 这是我创build线的代码: CAShapeLayer *line = [CAShapeLayer layer]; // Using bezierpath to make line UIBezierPath *linePath=[UIBezierPath bezierPath]; // Creating L with line [linePath moveToPoint:point1]; [linePath addToPoint:point2]; [linePath addToPoint:point3]; line.path=linePath.CGPath; // Configure the appearence of the line line.fillColor = Nil; line.opacity = 1.0; line.strokeColor = [UIColor whiteColor].CGColor; 任何想法,这将非常感激。

在imageview中调整线条以适合我们的头部

我正在开发一个与HairTryOn相同的应用程序。 但在下面的图像中显示问题。 我想根据客户的脸部设置发型,使用蓝色线条按照图像中的显示。 我用下面的代码 testVw = [[UIView alloc]initWithFrame:CGRectMake(100,100, 100, 100)]; testVw.backgroundColor = [UIColor clearColor]; [self.view addSubview:testVw]; resizeVw = [[UIImageView alloc]initWithFrame:CGRectMake(testVw.frame.size.width-25, testVw.frame.size.height-25, 25, 25)]; resizeVw.backgroundColor = [UIColor clearColor]; resizeVw.userInteractionEnabled = YES; resizeVw.image = [UIImage imageNamed:@"button_02.png" ]; [testVw addSubview:resizeVw]; UIPanGestureRecognizer* panResizeGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(resizeTranslate:)]; [testVw addGestureRecognizer:panResizeGesture]; resizeTranslate:方法: -(void)resizeTranslate:(UIPanGestureRecognizer *)recognizer { if ([recognizer state]== UIGestureRecognizerStateBegan) { […]

绘制平滑的曲线

我有两个点左右增加一些静态值的Y和X是左右两边的AVG我创build了第三点中心 之后,我用他们之间的贝塞尔path绘制曲线和所有工作正常。 在上面的曲线 现在我想创build两个点(5点曲线)。 一个在中间和左边之间,一个在中间和右边之间。 我试图再次采取平均和使用5点曲线 func drawFivePoint(_ startPoint: CGPoint?, leftCenterPoint: CGPoint?, toControlPoint controlPoint: CGPoint?, toRightControlPoint rightPoint: CGPoint?, toEnd endPoint: CGPoint?) { var arrPoints = [NSValue]() if startPoint != nil { arrPoints.append(NSValue(cgPoint: startPoint!)) } if leftCenterPoint != nil && !(__CGPointEqualToPoint(leftCenterPoint!, .zero)) { arrPoints.append(NSValue(cgPoint: leftCenterPoint!)) } if controlPoint != nil { arrPoints.append(NSValue(cgPoint: controlPoint!)) } if rightPoint […]

如何在iPhone SDK中findclosurespath(两行交集)?

请看图片。 我怎样才能得到两个交点(即绿色圆点)? 我想裁剪图像的内部。 closures的path是任何地方在线。 context = UIGraphicsGetCurrentContext(); CGContextBeginPath(context); CGContextSetLineWidth(context, 1.0 * self.scale); CGContextSetLineCap(context, kCGLineCapRound); [[UIColor redColor] setStroke]; CGPoint firstPoint = CGPointFromString([self.touchPoints objectAtIndex:0]); CGContextMoveToPoint(context, firstPoint.x, firstPoint.y); for (NSString *pointString in self.touchPoints) { CGPoint point = CGPointFromString(pointString); CGContextAddLineToPoint(context, point.x, point.y); } CGContextStrokePath(context); 这个代码用于绘制线条。 线条工作正常,裁剪也工作正常…但交叉点是我的主要问题。 请帮帮我。

带有使用UIBezierPath的圆angular的多边形

我想使用UIBezierPath创build一个圆angular的多边形形状。 我相信这将可能使用addCurveToPoint:controlPoint1:controlPoint2:和类似的代码findhttp://www.codeproject.com/Articles/31859/Draw-a-Smooth-Curve-through-a-Set-of-二维点 – 机智 ,但我想知道是否有任何现有(或更好)的方式来实现这一目标? 我应该指出,这将需要为任何凸多边形(如在voronoi图中发现),而不是一个矩形的形状。

ios检测线的angular度或程度

我是新来的iOS ,我正在尝试开发一个写意画应用程序,使用uibezierPath有一种方法来计算或接收总线的长度,即使我画了直线,弯曲或一个圆。 我在touchmove方法上使用addline,而我没有任何控制点。

需要与UIBezierPath的提示。 像Instagram注册视图的三angular形状

我正在试图创build一个像下面的图片中的instagram三angular形的贝塞尔path,但是我一定是做错了什么。 贝塞尔path不显示! – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } -(void)viewDidLayoutSubviews{ [super viewDidLayoutSubviews]; [self drawTriangle]; } – (IBAction)closeButton:(UIButton *)sender { [self dismissViewControllerAnimated:YES completion:nil]; } – (void)drawTriangle{ UIBezierPath* trianglePath = [UIBezierPath bezierPath]; [trianglePath moveToPoint:CGPointMake(self.signUpButton.center.x, self.signUpButton.frame.origin.y + 30)]; [trianglePath addLineToPoint:CGPointMake(self.signUpButton.center.x – 10, self.imageView.frame.size.height)]; [trianglePath addLineToPoint:CGPointMake(self.signUpButton.center.x + 10, self.imageView.frame.size.height)]; UIColor *fillColor […]

如何在iOS中使用bezierpath创build月牙形月亮?

如何使用bezierpath绘制一个闭合的新月,当笔画和填充是可configuration的? 所以汽车我可以得到一次曲线,但还没有find一个策略来连接和绘制另一条曲线。

添加一个QuadCurve到UIBezierPath

我正在做一个绘图应用程序,我试图平滑我用手指画的线。为此,我正在使用“quadCurveToPoint”function。 但是,我没有得到正确的答案。 以下是我的代码: – (void) drawRect:(CGRect)rect { [path stroke]; } – (id) initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) self.multipleTouchEnabled = NO; path = [UIBezierPath bezierPath]; path.lineWidth = IS_IPAD? 2.0f : 1.0f; return self; } – (void) touchesBegan:(NSSet *) touches withEvent:(UIEvent *) event { UITouch *touch = [touches anyObject]; m_previousPoint1 = [touch locationInView:self]; m_previousPoint2 = […]

在iOS 7上疯狂的圆angular矩形UIBezierPath行为。什么是交易?

下面的简单的UIView绘制一个圆angular的矩形。 当我通过一个65或以下的angular半径,它正确的轮,但66和以上,它会产生一个完美的圆圈! 这里发生了什么? 当边angular半径等于边框宽度的1/2时,应该只显示一个圆,但不pipe视图的大小是多less,当半径大约是1/3时,似乎都会画一个圆。 这种行为出现在iOS 7上。在iOS 6上,我得到了预期的行为。 #import "ViewController.h" @interface MyView : UIView @end @implementation MyView -(void)drawRect:(CGRect)rect { UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 200, 200) cornerRadius:65]; CGContextRef c = UIGraphicsGetCurrentContext(); CGContextAddPath(c, path.CGPath); [[UIColor redColor] set]; CGContextStrokePath(c); } @end @interface ViewController () @end @implementation ViewController – (void)viewDidLoad { [super viewDidLoad]; MyView *v = [[MyView alloc] […]