标签: uibezierpath

在iOS中绘制线条时命中检测

我想允许用户绘制曲线,使得任何线都不能穿过另一条线甚至自身.绘制曲线是没有问题的,我甚至发现我可以通过追踪线的节点向前和向后然后关闭路径来创建一个闭合的路径,并且仍然是线条状的.

不幸的是,iOS只提供了一个测试点是否包含在一个封闭的路径中(containsPoint:和CGPathContainsPoint).不幸的是,用户可以非常容易地移动他们的手指足够快以使触摸点落在现有路径的两侧而实际上不被该路径包含,因此测试触摸点是非常没有意义的.

我找不到任何"路口"的路径方法.

关于如何完成这项任务的任何其他想法?

cocoa-touch hittest ios uibezierpath

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

如何获取UIBezierPath的反向路径

self.myPath=[UIBezierPath bezierPathWithArcCenter:center 
                                           radius:200 
                                       startAngle:0 
                                         endAngle:180 
                                        clockwise:YES];
Run Code Online (Sandbox Code Playgroud)

(这让我能够通过一些网络搜索来运行起来).

我有这条路.现在我想填补这条路径的反面,所以留下这部分并填充其他所有内容.我怎样才能完成编码?我对此没有太多信息.

问题

在此输入图像描述

在使用Cemal之后它显示的区域之前它只显示了一个带红色笔划的圆圈.

编辑

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        self.punchedOutPath =  
         [UIBezierPath bezierPathWithOvalInRect:CGRectMake(50, 50, 400, 400)];
        self.fillColor = [UIColor redColor];
        self.alpha = 0.8;
    }
    return self;
}

- (void)drawRect:(CGRect)rect
{
    [[self fillColor] set];
    UIRectFill(rect);

    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextSetBlendMode(ctx, kCGBlendModeDestinationOut);

    [[self punchedOutPath] fill];

    CGContextSetBlendMode(ctx, kCGBlendModeNormal);
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

iphone objective-c ios uibezierpath

13
推荐指数
3
解决办法
1万
查看次数

在一组给定点之间绘制贝塞尔曲线

在iOS应用程序中绘制贝塞尔曲线的最佳方法是什么,它通过一组给定的点

bezier ios uibezierpath

13
推荐指数
2
解决办法
2万
查看次数

IOS:从线到Bezier曲线的动画转换

我想动画一条弯曲成bezier曲线的直线(从"_"到"n"),是否有一个可以帮助我完成它的库?

我知道如何使用UIBezierPath绘制Bezier曲线,我可以快速重绘并逐步进行转换,但是如果已经做了某些事情就会很酷:-)

bezier core-graphics ios nsbezierpath uibezierpath

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

Swift:来自Center的UIBezierPath Stroke动画

我一直UIBezierPath用Swift 做一个简单的动画.此路径包括创建带有彩色边框的圆角矩形.动画必须是彩色边框的绘图.为此,我创建了一个CAShapeLayer带有UIBezierPath(roundedRect:, cornerRadius: )

let layer = CAShapeLayer()
var viewPrueba = UIView()

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    viewPrueba = UIView(frame: CGRectMake(self.view.frame.width/2-100, self.view.frame.height/2 - 100, 200, 200))
    self.view.addSubview(viewPrueba)
    let path = UIBezierPath(roundedRect: CGRectMake(0, 0, 200, 200), cornerRadius: 40.0)
    layer.path = path.CGPath
    layer.fillColor = UIColor.clearColor().CGColor
    layer.strokeColor = UIColor.blueColor().CGColor
    layer.strokeStart = 0.0
    layer.strokeEnd = 0.0
    layer.lineWidth = 4.0
    layer.lineJoin = kCALineJoinRound
    viewPrueba.layer.addSublayer(layer)
    let tapGR = …
Run Code Online (Sandbox Code Playgroud)

animation stroke ios uibezierpath swift

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

我可以结合多个透明SCNShape对象吗?

我正在向ARSCNSceneView场景添加多个透明SCNShape对象.

  • 这些形状基于用户输入,应该重叠.
  • 它们都是在同一平面上用UIBezierPath制成的扁平形状
  • 形状必须是透明的,因此用户可以看到后面的摄像头输入

问题是重叠的形状是非常明显的,我希望它显示为一个单一的形状 - 所有形状的结合.

失败的方法:

  • 将它放在同一节点下并使用父不透明度.
  • 合并UIBezier路径.
  • 混合模式
  • 透明模式
  • 使用原始三角形而不是UIBezierPath绘图

想要与目前的结果

ios uibezierpath scenekit swift arkit

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

如何在UIBezierPath中填充颜色?

我在touchesMoved中通过UIBezierPath绘制一个形状.

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    secondPoint = firstPoint;
    firstPoint = [touch previousLocationInView:self];
    currentPoint = [touch locationInView:self];

    CGPoint mid1 = midPoint(firstPoint, secondPoint);
    CGPoint mid2 = midPoint(currentPoint, firstPoint);

    [bezierPath moveToPoint:mid1]; 
    [bezierPath addQuadCurveToPoint:mid2 controlPoint:firstPoint];

    [self setNeedsDisplay]; 
}
Run Code Online (Sandbox Code Playgroud)

我想在closePath之后填充其中的RED颜色但不能.请帮忙!

- (void)drawRect:(CGRect)rect
{
    UIColor *fillColor = [UIColor redColor];
    [fillColor setFill];
    UIColor *strokeColor = [UIColor blueColor];
    [strokeColor setStroke];
    [bezierPath closePath];
    [bezierPath fill];
    [bezierPath stroke]; 
}
Run Code Online (Sandbox Code Playgroud)

ios uibezierpath

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

为CAShapeLayer设置动画以绘制进度圆

我想画一个用来表示进展的圆圈.进度更新可能会很快进行,我想对圆圈的更改进行动画处理.

我已尝试使用以下方法执行此操作,但似乎没有任何工作.这可能吗?

- (id)initWithFrame:(CGRect)frame strokeWidth:(CGFloat)strokeWidth insets:(UIEdgeInsets)insets
{
    if (self = [super initWithFrame:frame])
    {

        self.strokeWidth = strokeWidth;

        CGPoint arcCenter = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds));
        CGFloat radius = CGRectGetMidX(self.bounds) - insets.top - insets.bottom;

        self.circlePath = [UIBezierPath bezierPathWithArcCenter:arcCenter
                                                         radius:radius
                                                     startAngle:M_PI
                                                       endAngle:-M_PI
                                                      clockwise:YES];
        [self addLayer];
    }
    return self;
}


- (void)setProgress:(double)progress {
    _progress = progress;
    [self updateAnimations];
}

- (void)addLayer {

    CAShapeLayer *progressLayer = [CAShapeLayer layer];
    progressLayer.path = self.circlePath.CGPath;
    progressLayer.strokeColor = [[UIColor whiteColor] CGColor];
    progressLayer.fillColor = [[UIColor clearColor] CGColor];
    progressLayer.lineWidth = self.strokeWidth;
    progressLayer.strokeStart = 10.0f;
    progressLayer.strokeEnd …
Run Code Online (Sandbox Code Playgroud)

core-animation objective-c cashapelayer ios uibezierpath

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

联盟UIBezierPaths而不是Apend路径

我有一个应用程序,我在其中使用UIBezierPath并通过一系列appendPath:调用将其用作画笔.经过一些事情,并且具有非常复杂的刷子形状,内存耗尽,应用程序停止运行.我真正想做的是完全一样的联盟,就像Paint Code一样,但我找不到任何方法这样做.

我如何加入两个或更多UIBezierPaths?

编辑:

这是我想要动态实现的视觉效果.

在Paint Code中,您将采用两条路径并将它们重叠,如下所示:

但我想将它们合并/合并为一个新的单一路径,如:

Paint Code中的合并路径

请注意,在Paint Code的底部面板中,现在有一个单一形状的代码,这就是我希望能够以编程方式获得1000条原始路径.

core-graphics ios uibezierpath

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

如何在UIView(iOS)中绘制心形?

我想创造不同的形状.下图是一个例子.你能告诉我如何塑造不同的形状吗?

在此输入图像描述

core-graphics cgcontext ios uibezierpath

12
推荐指数
4
解决办法
1万
查看次数