let animation = CAKeyframeAnimation (keyPath: "position" )
//设置5个位置点
let p1 = CGPointMake (0.0, 0.0)
let p2 = CGPointMake (300, 0.0)
let p3 = CGPointMake (0.0, 400)
let p4 = CGPointMake (300, 400)
let p5 = CGPointMake (150, 200)
//赋值
animation.values = [ NSValue ( CGPoint : p1), NSValue ( CGPoint : p2),
NSValue ( CGPoint : p3), NSValue ( CGPoint : p4), NSValue ( CGPoint : p5)]
//每个动作的时间百分比
animation.keyTimes = [ NSNumber (float: 0.0), NSNumber (float: 0.4),
NSNumber (float: 0.6), NSNumber (float: 0.8), NSNumber (float: 1.0), ]
animation.delegate = self
animation.duration = 6.0
self .imageView.layer.addAnimation(animation, forKey: "Image-Move" )
|