- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我尝试使用以下代码绘制如下形状时,该形状仅显示半笔划线。
let shape = SKShapeNode()
shape.path = createPointerPath().cgPath
shape.position = CGPoint(x: frame.midX, y: frame.midY)
shape.fillColor = UIColor(red: 1.0, green: 0.439, blue: 0.678, alpha: 1.0)
shape.strokeColor = .white
shape.lineWidth = 2
addChild(shape)
创建形状:
func createPointerPath() -> UIBezierPath {
let pointerPath = UIBezierPath()
pointerPath.move(to: CGPoint(x:0, y:0))
pointerPath.addCurve(to: CGPoint(x:0, y:100), controlPoint1: CGPoint(x:-10, y:0), controlPoint2: CGPoint(x:-50, y:100))
pointerPath.addCurve(to: CGPoint(x:0, y:0), controlPoint1: CGPoint(x:50, y:100), controlPoint2: CGPoint(x:10, y:0))
pointerPath.stroke()
pointerPath.close()
return pointerPath
}
如果我将 x 设置为 10,它会显示另一条 half stroe 线,但形状没有闭合。
pointerPath.addCurve(to: CGPoint(x:10, y:0), controlPoint1: CGPoint(x:50, y:100), controlPoint2: CGPoint(x:10, y:0))
有什么建议吗?谢谢!
最佳答案
这是我尝试后得到的;希望对你有帮助
let v : UIView = UIView.init(frame: CGRect.init(x: 50, y: 50, width: 200, height: 200))
v.layer.borderWidth = 2.0
let shape = CAShapeLayer()
shape.path = createPointerPath().cgPath
shape.position = CGPoint(x: frame.midX, y: frame.midY)
shape.fillColor = UIColor(red: 1.0, green: 0.439, blue: 0.678, alpha: 1.0).cgColor
shape.strokeColor = UIColor.white.cgColor
shape.lineWidth = 2
v.layer.addSublayer(shape)
self.addSubview(v)
这与您提供的功能相同:
func createPointerPath() -> UIBezierPath {
let pointerPath = UIBezierPath()
pointerPath.move(to: CGPoint(x:0, y:0))
pointerPath.addCurve(to: CGPoint(x:0, y:100), controlPoint1: CGPoint(x:-10, y:0), controlPoint2: CGPoint(x:-50, y:100))
pointerPath.addCurve(to: CGPoint(x:0, y:0), controlPoint1: CGPoint(x:50, y:100), controlPoint2: CGPoint(x:10, y:0))
pointerPath.stroke()
pointerPath.close()
return pointerPath
}
输出:
关于ios - UIBezierPath 只有半个笔画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42799343/
我正在开发一个基于fabricjs 的图表工具。我们的工具有我们自己的形状集合,它是基于 svg 的。我的问题是当我缩放对象时,边框(描边)也会缩放。我的问题是:如何缩放对象但保持笔触宽度固定。请检查
我在 Canvas 上画线时遇到一点问题, 基本上我希望线条漂亮、柔软且半不透明,但 Canvas 似乎只想对最后渲染的线段执行此操作。 看看这里,您会看到最后绘制的线段很好,而且..我想要它)但是随
也许这是一个错误,但请检查一下。 https://codepen.io/Firsh/pen/LegGQq /* Only these work:*/ /* symbol{ overflow: visi
我已经在终端中启动了一个 python 脚本(该终端已关闭)并将其发送到后台。现在这个程序需要一些来自键盘的输入并一直等待。如何将输入“y\n”(字母“y”后跟一个 Enter)发送到该程序?假设它的
我想实现这样的效果: 有人知道如何在 Canvas 上画这样一条线吗? 最佳答案 再靠近一点: chalkPaint = new Paint(); chalkPaint.setStyl
我建立了一个very simple Twitter Instant Search为了好玩,使用 jQuery 和 PHP。我将一个事件绑定(bind)到搜索表单上的 keyup,并对 PHP 页面进行
使用通用 Windows 平台 (UWP) 使用 InkCanvas 控件 我似乎无法确定在使用 InkCanvas 时删除墨迹笔划的正确方法 - 有一个可以处理的事件“StrokeErased”。
我是一名优秀的程序员,十分优秀!