UIView 或 图片 实现动画效果
UIView 实现动画效果:
1.设置全局UIView动画
UIView.animateWithDuration(1, delay: 0.3, options: .Repeat | .CurveEaseIn, animations: { self.qrscan.frame = CGRectMake(113, 350, 94, 2) self.qrscan.animationRepeatCount = 0 }, completion: {finished in println("moved!") //self.qrStopMove() })
2 .单独设置轨迹动画:
let anim = CAKeyframeAnimation(keyPath: "position") let path = UIBezierPath() path.moveToPoint(CGPoint(x: 160,y: 130)) //113, 130 //x: 16,y: 239 path.addCurveToPoint(CGPoint(x: 160, y: 350), controlPoint1: CGPoint(x: 160, y: 200), controlPoint2: CGPoint(x: 160, y: 270)) anim.path = path.CGPath anim.repeatCount = Float.infinity anim.duration = 3.0 qrscan.layer.addAnimation(anim, forKey: "QR-animate")