草庐IT

uibezierpath

全部标签

ios - UIBezierPath 更改路径段的宽度

我正在尝试开发一个绘图应用程序,我需要根据手的速度改变路径的宽度。我尝试使用moveToPoint来启动另一个子路径myPath.moveToPoint(myPath.currentPoint)myPath.lineWidth=myPath.lineWidth+1但它不起作用,它改变了整个路径的宽度。你知道是否有办法只改变子路径的宽度吗? 最佳答案 那是不可能的。所有UIBezierPath属性(lineWidth、flatness...)都适用于整个路径及其所有子路径。要绘制具有不同线宽的曲线,您必须创建多个贝塞尔曲线路径。

ios - 如何在 swift 中动画绘制 UIBezierPath

有人知道如何在自定义View中为UIBezierPath的绘图设置动画吗?所以看起来iPhone拿起了一支笔并在屏幕上绘图,速度足够慢,可以看到它。就说我有如下路径:varbezierPath=UIBezierPath()bezierPath.moveToPoint(CGPointMake(49.5,14.5))bezierPath.addCurveToPoint(CGPointMake(106.5,14.5),controlPoint1:CGPointMake(106.5,14.5),controlPoint2:CGPointMake(106.5,14.5))bezierPath.a

ios - UIBezierPath 创建三角形、正方形、圆形 Swift

我正在尝试创建三种形状:圆形、方形和三角形。我已经创建了圆形和正方形,但无法创建三角形。我最大的问题是将所有三个形状都保持在屏幕中央。圆形和正方形都很好,但是当我尝试制作三角形时它不起作用。我还试图让三角形看起来像一个“播放按钮”,以便三角形的“尖端”朝向右侧。这是代码。functrainglePathWithCenter(center:CGPoint,side:CGFloat)->UIBezierPath{letpath=UIBezierPath()letstartX=center.x-side/2letstartY=center.y-side/2path.move(to:CGPoi

Swift - 调用中的 UIBezierPath 额外参数 'radius'

我正在将Objective-C库(STKSpinnerView)改编为Swift,但我无法解决这个错误:funcgetRadius()->CGFloat{varr:CGRect=CGRectInset(self.bounds,self.wellThickness/2.0,self.wellThickness/2.0)varw:CGFloat=r.size.widthvarh:CGFloat=r.size.heightifw>h{returnh/2.0}else{returnw/2.0}}overridefunclayoutSubviews(){super.layoutSubviews(

ios - 为 CAGradientLayer 添加 mask 使 UIBezierPath 消失

我想为带有渐变的View添加内边框。下面的代码有效并给了我这个结果importUIKitclassInnerGradientBorderView:UIView{overrideinit(frame:CGRect){super.init(frame:frame)backgroundColor=UIColor.clear}requiredinit?(coderaDecoder:NSCoder){super.init(coder:aDecoder)backgroundColor=UIColor.clear}overridefuncdraw(_rect:CGRect){super.draw(r

ios - UIView 上 swift 3 中的 uibezierPath,只需要曲线

当我在UIView上快速绘制bezierPath时。我得到了直线。我只需要曲线是否可以删除直线。我可以通过以下方式去除灰色填充:line.fillColor=UIColor.clear.cgColor不知道如何删除直线代码:letline=CAShapeLayer()letlinePath=UIBezierPath()linePath.move(to:start)linePath.addLine(to:end)vardis=(end.x-start.x)/3.0linePath.addCurve(to:start,controlPoint1:CGPoint(x:start.x+dis,

swift - 2 UIBezierPath的绘制差异

我想绘制2个UIBezierPath之间的差异(参见屏幕截图)以便仅绘制圆角,如您在我的屏幕截图(图C)中所见这是我的代码:letcontext=UIGraphicsGetCurrentContext()CGContextSaveGState(context)letrectanglePath=UIBezierPath(rect:rect)CGContextAddPath(context,rectanglePath.CGPath)CGContextEOClip(context)letroundedRectanglePath=UIBezierPath(roundedRect:product

ios - 使用圆形 UIBezierPath 和 CABasicAnimation 为 CAShapeLayer 设置动画

我想在15秒内为一个从0度到360度的圆制作动画。动画很奇怪。我知道这可能是一个开始/结束角度问题,我已经遇到过圆形动画的那种问题,但我不知道如何解决这个问题。varcircle_layer=CAShapeLayer()varcircle_anim=CABasicAnimation(keyPath:"path")funcinit_circle_layer(){letw=circle_view.bounds.widthletcenter=CGPoint(x:w/2,y:w/2)//initialpathletstart_angle:CGFloat=-0.25*360*CGFloat.pi

swift - Swift 中的 UIBezierPath 描边(和填充)

我正在努力寻找一种快速绘制(和填充)贝塞尔曲线路径的方法。这是我认为行得通但行不通的方法。varmyBezier=UIBezierPath()myBezier.moveToPoint(CGPoint(x:0,y:0))myBezier.addLineToPoint(CGPoint(x:100,y:0))myBezier.addLineToPoint(CGPoint(x:50,y:100))myBezier.closePath()UIColor.setStroke(UIColor.blackColor())myBezier.stroke()行UIColor.setStroke(UICol

ios - 两个 UIBezierPaths 交集作为一个 UIBezierPath

我有两个UIBezierPath,一个表示图像的多边形部分,另一个是要在其上绘制的路径。我需要找到它们之间的交点,以便只有在这个交点区域内的点才会被着色。UIBezierPath中是否有一种方法可以找到两条路径之间的交点或新路径? 最佳答案 我不知道有什么方法可以获取两条路径相交的新路径,但您可以通过使用每条路径的裁剪属性来填充或以其他方式绘制交点。在这个例子中,有两条路径,一个正方形和一个圆:letpath1=UIBezierPath(rect:CGRect(x:0,y:0,width:100,height:100))letpat