ios - 从 ccore 动画中的形状中删除黑色填充颜色
问题描述
我正在制作一个动画,其中图像在曲线路径中随线条移动。我能够画线并移动飞机,但我在路径中得到了一个黑色填充部分。如何删除它?请在这里查看
以下是我创建动画的代码:
func animate(image: UIView, fromPoint start: CGPoint, toPoint end: CGPoint) {
// The animation
let animation = CAKeyframeAnimation(keyPath: "strokeEnd")
// Animation's path
let path = UIBezierPath()
// Move the "cursor" to the start
path.move(to: start)
path.addLine(to: start)
// Calculate the control points
let c1 = CGPoint(x: end.x - 30, y: start.y)
let c2 = CGPoint(x: end.x, y: start.y - 30)
// Draw a curve towards the end, using control points
path.addCurve(to: end, controlPoint1: c1, controlPoint2: c2)
// Use this path as the animation's path (casted to CGPath)
animation.path = path.cgPath
// The other animations properties
animation.fillMode = CAMediaTimingFillMode.forwards
animation.isRemovedOnCompletion = false
animation.duration = 3.0
animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
// Apply it
image.layer.add(animation, forKey: "position")
let shapeLayer = CAShapeLayer()
shapeLayer.strokeColor = R.color.MyPurple()?.cgColor
shapeLayer.lineWidth = 3
shapeLayer.path = path.cgPath
self.view.layer.addSublayer(shapeLayer)
}
解决方案
请添加以下行:
shapeLayer.fillColor = UIColor.clear.cgColor
推荐阅读
- r - R:使用 tidyverse 对组进行上下预测
- javascript - 如何修复其他类中的方法
- json - 无法使用 json 包读取我的 json 文件
- unity3d - Unity:如何获得固定关节组件?
- express - 所有 cassandra 物化视图未配置表
- regex - 使用 RE2 Regexp_Extract 在管道之间提取内容
- python-3.x - 如何确保终端搜索 venv 文件夹而不是第三方模块的默认 python 位置?
- java - Objectify 单元测试将数据持久化到 Google Cloud Datastore
- r - XML 到具有重复同级的数据框
- haskell - GHCi ":browse" 如何导入模块?