Tag: uibezierpath

CGPath和UIBezierPath()有什么区别?

目前,我正在努力解决如何animation自定义button,我有一个图像和坐标,但我发现你可以通过使用CGPath类或UIBezierPath创build一个button/对象类。 有人可以告诉我两者之间的区别是什么?

如何填充两个UIBezierPath之间的空间

我正在绘制应用程序,它提供了可变的线宽,这取决于绘制速度。 这个行为受到了Paper app的启发。 我试图实现的algorithm – 绘制两个彼此之间可变距离的贝塞尔path。 在sosborn的答案中描述的解决scheme。 然后平滑path并填充它们之间的距离。 其实我不知道如何填补path之间的空间。

UIBezierPath:不正确的视图截图检索

我正在采取以下方式截图。 – (UIImage*)screenshot { UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; CGRect rect = [keyWindow bounds]; UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); [keyWindow.layer renderInContext:context]; UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return img; } 在UIView我使用UIBezierPath绘制path。 我得到的屏幕截图是不正确的 任何想法为什么上半部分是空白? 在UIView所有绘图显示正确。 更新:当我释放我的画笔并获得正确的屏幕截图时,使用UIBezierPath绘制长path时,会发生这种情况。

为什么CGPath和UIBezierPath在SpriteKit中定义“顺时针”?

在SpriteKit中, clockwise方向对于UIBezierPath是颠倒的,而对于CGPath不是。 例如,如果我有 do { let path = CGPathCreateMutable() CGPathAddArc(path, nil, 0, 0, 10, 0, CGFloat(M_PI_2), true) let node = SKShapeNode(path: path) node.position = CGPoint(x: self.size.width/2, y: self.size.height/2) self.addChild(node) } do { let path = UIBezierPath() path.addArcWithCenter(CGPoint(x: 0, y: 0), radius: 10, startAngle: 0, endAngle: CGFloat(M_PI_2), clockwise: true) let node = SKShapeNode(path: path.CGPath) node.position = […]

创build一个具有圆顶的UIView

我想创build一个像这个图像圆顶的UIView,我该怎么做? 想要的结果 不想要的结果

用UIBezierPath单行绘制字母(文本)

我正在使用这个和这个参考。 我是新的使用UIBezierPath,我想绘制字符(字母)代码我使用的path如下。 CGMutablePathRef letters = CGPathCreateMutable(); CTFontRef font = CTFontCreateWithName(CFSTR("Courier New"), 200.0f, NULL); NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:CFBridgingRelease(font), kCTFontAttributeName,nil]; NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"B" attributes:attrs]; CTLineRef line = CTLineCreateWithAttributedString((CFAttributedStringRef)attrString); CFArrayRef runArray = CTLineGetGlyphRuns(line); // for each RUN for (CFIndex runIndex = 0; runIndex < CFArrayGetCount(runArray); runIndex++) { // Get FONT for this run CTRunRef […]

贝塞尔path看它是否穿越

我有一个让用户绘制形状的代码,我使用UIBezierPath。 但是我需要看看形状是否自相交叉,例如像这样: http : //upload.wikimedia.org/wikipedia/commons/0/0f/Complex_polygon.svg然后它不是一个有效的形状。 我怎样才能find这个? 编辑:我还没有解决这个。 我保存数组中path之间的所有点。 然后我遍历数组,并尝试查找是否有任何线相交。 但是它不起作用,有时它说不存在交叉点。 我认为这个问题是在这个方法的某个地方。 -(BOOL)pathIntersects:(double *)x:(double *)y { int count = pathPoints.count; CGPoint p1, p2, p3, p4; for (int a=0; a<count; a++) { //Line 1 if (a+1<count) { p1 = [[pathPoints objectAtIndex:a] CGPointValue]; p2 = [[pathPoints objectAtIndex:a+1] CGPointValue]; }else{ return NO; } for (int b=0; b<count; b++) { […]

UIBezierPath指向小path

给定一个任意的UIBezierPath ,我正在寻找一种方法来得到一个点的path长度的一小部分。 例: UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:CGPointMake(200.0, 200.0)]; [path addLineToPoint:CGPointMake(200.0, 400.0)]; CGPoint p = [path pointAtFraction:0.5]; 在这种情况下{x: 200.0, y: 300.0} p应该是{x: 200.0, y: 300.0} 。 我知道这个简单的例子可以计算,但我正在寻找一个解决scheme,适合任何UIBezierPath (圆弧,圆angularUIBezierPath等) 看到基本生活在UIBezierPath及其属性strokeEnd ,我想信息是在path对象内的某个地方。 但是, UIBezierPath和CGPathRef接口都不能显示任何方式来实现这一点。 我尝试创build一个CAShapeLayer ,设置strokeEnd并从图层中检索CGPathRef ,但path保持不变。 有没有什么办法(公共API)来实现这一目标?

如何在iOS中使用弧形边缘绘制弧形?

在我的应用程序之一,我想绘制一个带圆angular的渐变弧。 像下面的图片 这是我迄今为止使用下面的代码所做的。 -(void)startArc { UIBezierPath *roundedArc = [self arcWithRoundedCornerAt:centerPoint startAngle:DEGREES_TO_RADIANS(-90) endAngle:DEGREES_TO_RADIANS(90) innerRadius:width-20 outerRadius:width cornerRadius:0]; CAShapeLayer *mask = [CAShapeLayer new]; [mask setPath:roundedArc.CGPath]; [mask setFrame:_outerView.bounds]; [mask setShouldRasterize:YES]; [mask setRasterizationScale:[UIScreen mainScreen].scale]; CAGradientLayer *gradient = [CAGradientLayer new]; [gradient setFrame:_outerView.bounds]; // [gradient setColors:[NSArray arrayWithObjects:(id)[[UIColor colorWithRed:0.86 green:0.91 blue:0.96 alpha:1.0f] CGColor],(id)[[UIColor colorWithRed:0.98 green:0.99 blue:0.99 alpha:1.0f] CGColor], nil]]; [gradient setColors:[NSArray arrayWithObjects:(id)[UIColor colorWithRed:0.19 […]

用CAShapeLayer和UIBezierPath剪辑屏蔽uiview

我有一个问题,使用CAShapeLayer-UIBezierPath剪辑视图,我想剪辑的内容,但我最终得到一个中风(框架)与该UIBezierPath,这是我的代码 UIBezierPath *path2Path = [UIBezierPath bezierPath]; [path2Path moveToPoint:CGPointMake(206.745, 0)]; [path2Path addLineToPoint:CGPointMake(206.745, 97.613)]; [path2Path addLineToPoint:CGPointMake(0, 97.613)]; [path2Path addLineToPoint:CGPointMake(0, 0)]; [path2Path addLineToPoint:CGPointMake(87.28, 0)]; [path2Path addCurveToPoint:CGPointMake(103.808, 12.118) controlPoint1:CGPointMake(87.28, 0) controlPoint2:CGPointMake(86.555, 12.118)]; [path2Path addCurveToPoint:CGPointMake(119.466, 0) controlPoint1:CGPointMake(121.061, 12.118) controlPoint2:CGPointMake(119.466, 0)]; [path2Path addLineToPoint:CGPointMake(206.745, 0)]; [path2Path closePath]; [path2Path addClip]; CAShapeLayer *pathLayer = [CAShapeLayer layer]; pathLayer.frame=MYVIEW.bounds; pathLayer.path = path2Path.CGPath; pathLayer.strokeColor = [[UIColor blackColor] […]