在iOS中播放准备好的动画 [英] Playing prepared animation in iOS

查看:61
本文介绍了在iOS中播放准备好的动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有由设计公司制作的动画(在700x700 px,透明背景下,大约需要6-7秒的时间)。
我需要在iOS应用的开头展示这些动画。
>
在应用程序中轻松使用它们的最佳方法/格式是什么?
我不想处理动画细节,因为它们都已经由设计师准备了。

We have animations (approx. 6-7 seconds in 700x700 px, in transparent background) which are prepared by a design company.
I need to show these as an introduction in the beginning of our iOS app.

What is the best way/format to use them easily in the app?
I don't want to deal with animation details because they are all prepared by designers already.

到目前为止,我们已经使用 UIView animationImages 功能尝试了png序列,但是这种方法不是内存友好。

We tried png sequences with UIView's animationImages feature so far, but this approach wasn't memory friendly.

您有什么建议?

推荐答案

尝试这种简单的方法:

let timer = Timer()

@IBOutlet weak var imageView: UIImageView!
override func viewDidLoad() {
    super.viewDidLoad()
    // I am using tiff image file  for animation.You can use png or jpg both will works...
    var imagesNames =  ["1.tiff","2.tiff","3.tiff","4.tiff","5.tiff","6.tiff","7.tiff","8.tiff","9.tiff","10.tiff","11.tiff","12.tiff","13.tiff","14.tiff","15.tiff"]

        var images = [UIImage]()

        for i in 0..<imagesNames.count{
            images.append(UIImage(named: imagesNames[i])!)
        }

        imageView.animationImages = images
        imageView.animationDuration = 2
        imageView.startAnimating()

    Timer.scheduledTimer(timeInterval: 4.0, target: self, selector: #selector(timeToMoveOn), userInfo: nil, repeats: true)
    }

注意::如果您不想重复动画。在计时器功能中,将 repeat (重复)设置为 false

Note: If you dont want the animation to be repeat.In timer function set repeat to false

     func timeToMoveOn() {    
     //Do you stuff here.After animation finished
        print("It Workes")
     }

     //To hide status bar.If you want to hide statusBar.
     override var prefersStatusBarHidden: Bool {
     return true
     }

输出:

这篇关于在iOS中播放准备好的动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆