Swift开发教程--如何播放图片动画

前端之家收集整理的这篇文章主要介绍了Swift开发教程--如何播放图片动画前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

废话少说,直接上代码

var barsAnim = UIImageView(frame: self.view.frame);

barsAnim.animationImages = NSArray() as [AnyObject];

barsAnim.animationImages?.append(UIImage(named: "wave_000")!);

barsAnim.animationImages?.append(UIImage(named: "wave_001")!);

barsAnim.animationImages?.append(UIImage(named: "wave_002")!);

barsAnim.animationImages?.append(UIImage(named: "wave_003")!);

barsAnim.animationImages?.append(UIImage(named: "wave_004")!);

barsAnim.animationImages?.append(UIImage(named: "wave_005")!);

barsAnim.animationDuration = 2;

barsAnim.animationRepeatCount = 0;

barsAnim.startAnimating();

self.view.addSubview(barsAnim);

猜你在找的Swift相关文章