如何解决从 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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。