swift中关键帧动画

前端之家收集整理的这篇文章主要介绍了swift中关键帧动画前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@IBOutlet weak var bgView: UIView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view,typically from a nib. } override func touchesBegan(_ touches: Set<UITouch>,with event: UIEvent?) { let animation = CAKeyframeAnimation() animation.duration = 0.5 let value1 = bgView.frame.origin let value2 = CGPoint.init(x: 0,y: 0) let value3 = CGPoint(x: 400,y: 200) animation.values = NSArray(objects: NSValue(cgPoint: value1),NSValue(cgPoint: value2),NSValue(cgPoint: value3)) as! [Any] bgView.layer.add(animation,forKey: "position") } 原文链接:https://www.f2er.com/swift/322335.html

猜你在找的Swift相关文章