标签: uibezierpath

使用UIBezierPath的带圆角的多边形

我想使用UIBezierPath创建一个带圆角的多边形.我相信这可以使用addCurveToPoint:controlPoint1:controlPoint2:http://www.codeproject.com/Articles/31859/Draw-a-Smooth-Curve-through-a-Set-of-2D-Points-wit中的类似代码,但我想知道是否有任何现有(或更好)的方法来实现这一目标?

我应该指出,这将需要针对任何凸多边形(例如在voronoi图中找到)而不仅仅是矩形形状.

core-graphics polygon ios uibezierpath

1
推荐指数
1
解决办法
5265
查看次数

如何在UiView中拖动UIBezierPath

我成功创建了UIBezierPath现在我想在UIView中拖动该事件在拖动事件(UIPanGestureRecognizer)上并获取该路径所争论的当前位置点.

是否有可能我们只能将UIBezierPath从一个地方拖到另一个地方?在UIView.

iphone xcode objective-c ios uibezierpath

1
推荐指数
1
解决办法
1482
查看次数

如何使用UIBezier Path创建形状

我希望使用UIBezier Path实现图像中显示的形状,并且图像中的块填充了形状,它显示了一个块被填充,如何实现这一点.

在此输入图像描述

我从这里尝试了以下代码

UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(0, 10)];
[path addQuadCurveToPoint:CGPointMake(200, 10) controlPoint:CGPointMake(100, 5)];
[path addLineToPoint:CGPointMake(200, 0)];
[path addLineToPoint:CGPointMake(0, 0)];
[path closePath];
Run Code Online (Sandbox Code Playgroud)

谢谢.

core-graphics objective-c uiimage ios uibezierpath

1
推荐指数
1
解决办法
735
查看次数

在UIView类别中创建UIBezierPath.没有显示

我试图在UIView类别中使用UIBezierPath创建一个三角形.但没有显示三角形.还得到一个:CGContextSetFillColorWithColor.所以我的问题是如何使用UIView类别制作三角形或任何路径.演示项目

#import "UIView+Bubble.h"
#import <QuartzCore/QuartzCore.h>

@implementation UIView (Bubble)

+(UIView *)makeBubble{
    UIView *customView = [[UIView alloc] init];
    customView.frame=CGRectMake(0, 0, 320, 500);
    UIBezierPath *triangle = [UIBezierPath bezierPath];
    [triangle moveToPoint:CGPointMake(100, 0)];
    [triangle addLineToPoint:CGPointMake(0, 100)];
    [triangle addLineToPoint:CGPointMake(200, 100)];
    [triangle closePath];
    [[UIColor blackColor] setFill];
    [triangle fill];
    customView.layer.shadowPath = [triangle CGPath];
    return customView;
}
@end
Run Code Online (Sandbox Code Playgroud)

在ViewController.m中使用它像: -

- (void)viewDidLoad
{
    UIView *helpBubble=[UIView makeBubble];
    [self.view addSubview:helpBubble];
}
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios objective-c-category uibezierpath

1
推荐指数
1
解决办法
1785
查看次数

如何使用UIBezierPath以一定角度绘制椭圆?

我正在使用以下UIBezierPath方法绘制椭圆:

UIBezierPath *bpath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(x, y, width, height)];
Run Code Online (Sandbox Code Playgroud)

这给了我类似下面的内容:

在此输入图像描述

但我想以如下角度绘制椭圆:

在此输入图像描述

我知道一个解决方案是旋转UIView.但我不能这样做,因为同一个视图包含其他bezier路径.所以我想知道是否有办法以一定的角度绘制这个椭圆?

core-graphics ellipse quartz-2d ios uibezierpath

1
推荐指数
1
解决办法
1632
查看次数

如何使用UIBezierPathwithArcCenter在iOS中绘制完整的圆圈?

我希望startAngle处于90度,即π/ 2,所以我想如果我将endAngle设为90度,那么它只会形成一个完整的圆,但是没有绘制任何东西.

当我将开始和结束角度设置为如下所示的不同程度时,绘制路径,但它不是一个完整的圆.

下面是我目前使用的代码,但是如果startAngle是90度以便绘制一个完整的圆圈,我似乎无法弄清楚endAngle应该是什么.

有人可以帮忙吗?

    override func drawRect(rect: CGRect) {
    let center = CGPoint(x: bounds.width / 2, y: bounds.height / 2)
    let radius: CGFloat = max(bounds.width, bounds.height)
    let startAngle: CGFloat = 3 * ? / 4
    let endAngle: CGFloat = ? / 4

    var path = UIBezierPath(arcCenter: center,
                               radius: bounds.width / 2 - arcWidth / 2,
                           startAngle: startAngle,
                             endAngle: endAngle,
                            clockwise: true)


    path.lineWidth = arcWidth
    path.lineCapStyle = kCGLineCapRound
    counterColor.setStroke()
    path.stroke()
}
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch ios uibezierpath swift

1
推荐指数
1
解决办法
1165
查看次数

如何在UIView上绘制签名

我是ios的新手.我需要创建一个textview或标签,我可以在其中签名.

在此输入图像描述

喜欢这张图片.

objective-c uiview uibezierpath

1
推荐指数
2
解决办法
1568
查看次数

如何在Swift中绘制余弦或正弦曲线?

我一直在试图弄清楚如何在这个项目中使用UIBezierPath,但我不知道如何实现这种绘图.我可以绘制一个圆弧,直线和直线,但我觉得这个很丢失.感谢帮助

uibezierpath swift

1
推荐指数
1
解决办法
4669
查看次数

如何从多个BezierPath创建多个路径

我正在使用swift 2.2并且我正在处理这样的问题:我有一个UIBezier对象的数组,我需要为它们创建一个笔划作为一个路径.

我以前有一个特殊的功能,但这种方法的优点,它创建了几个层.这符合我的要求,因为我需要一层

 func createStroke(line: UIBezierPath) {

        self.currentPath = CAShapeLayer()
        currentPath.path = line.CGPath
        currentPath.strokeColor = UIColor.blackColor().CGColor
        currentPath.fillColor = UIColor.clearColor().CGColor
        currentPath.lineWidth = 1
        self.view.layer.addSublayer(currentPath)

    }
Run Code Online (Sandbox Code Playgroud)

从贝塞尔线阵列创建多路径的最佳方法是什么?第一个想法是创建一个for循环循环,但我认为它不是一个干净的方式.

arrays bezier cashapelayer uibezierpath swift

1
推荐指数
1
解决办法
1400
查看次数

如何为CGpath数组的绘制设置动画?

我正在尝试制作一个为用户绘制对象的应用程序.我现在有一个这样的对象,它是由一个类型的数组构成的[UIBezierPath].然后我使用循环UIBezierPath将数组中的所有s 更改为CGPaths,然后想要逐个绘制那些路径的动画.但是,当我尝试使用此代码时,它不起作用,我无法在网上找到任何有用的信息.这是代码被使用来转换阵列macbookPath它由UIBezierPathCGPath:

for path in macbookPath {
        drawingPath.append(path.cgPath)
    }
Run Code Online (Sandbox Code Playgroud)

然后我使用此代码尝试绘制路径:

for cgPath in drawingPath {
        shapeLayer.path = cgPath
    }
Run Code Online (Sandbox Code Playgroud)

这是函数的其余代码,drawForm()它应该将表单绘制到一个名为的视图上aiDrawView:

@objc func drawForm() {
    var drawingPath = [CGPath]()
    var macbookPath = Forms.MacbookForm()
    let shapeLayer = CAShapeLayer()
    shapeLayer.frame = aiDrawView.bounds

    for path in macbookPath {
        drawingPath.append(path.cgPath)
    }

    for cgPath in drawingPath {
        shapeLayer.path = cgPath
    }

    let strokeEndAnimation = CABasicAnimation(keyPath: "strokeEnd")
    strokeEndAnimation.duration = 2.0
    strokeEndAnimation.fromValue …
Run Code Online (Sandbox Code Playgroud)

cabasicanimation cashapelayer cgpath uibezierpath swift

1
推荐指数
1
解决办法
305
查看次数