【发布时间】:2017-07-12 23:43:00
【问题描述】:
我有一个上传 UIButton 并且我正在尝试实现一个动画,其中我有一组单独的点,它们在按钮下方水平排列,并且最左边的点淡入/淡出,然后在下一个点它淡入/淡出,一直到最右边的点,然后从左边重新开始循环。我可以对一个点进行此操作,但是对多个点执行此操作的最有效方法是什么?
func dotAnimation(){
let xCoord = self.recButt.frame.origin.x + 25
let yCoord = self.recButt.frame.origin.y + 5
let radius = 3
let dotPath = UIBezierPath(ovalIn: CGRect(x: Int(xCoord), y: Int(yCoord), width: radius, height: radius))
let layer = CAShapeLayer()
layer.path = dotPath.cgPath
layer.strokeColor = UIColor(red: 95.00/255, green: 106.00/255, blue: 255/255, alpha: 1.00).cgColor
self.view.layer.addSublayer(layer)
let animation : CABasicAnimation = CABasicAnimation(keyPath: "opacity");
animation.autoreverses = true
animation.fromValue = 0
animation.toValue = 1
animation.duration = 2.0
layer.add(animation, forKey: nil)
}
【问题讨论】:
标签: ios swift3 uiviewanimation cabasicanimation