gpt4 book ai didi

ios - 动画在 Swift 3 Xcode 8.1 中没有动画

转载 作者:行者123 更新时间:2023-11-28 08:20:10 24 4
gpt4 key购买 nike

当我使用以下代码运行我的应用程序时,它只显示第一帧,不会循环显示其他图像。

class ViewController: UIViewController, UITextFieldDelegate {

var signUpMode = true
var activityIndicator = UIActivityIndicatorView()


@IBOutlet weak var emailText: UITextField!
@IBOutlet weak var passwordText: UITextField!
@IBOutlet weak var signIn: UIImageView!

//Animated sign in
var counter = 0

var animationStart = false

var timer = Timer()

func animateSignIn() {

signIn.image = UIImage(named: "frame_\(counter)_delay-0.04s.gif")

counter += 1

if counter == 128 {

counter = 0

}
}

func animation (){

if animationStart == true {

timer = Timer.scheduledTimer(timeInterval: 0.04, target: self, selector: #selector(ViewController.animateSignIn), userInfo: nil, repeats: true)
}
}

然后我将 animationStart 设置为 true:

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//remove root view controller navigation bar
self.navigationController?.navigationBar.isHidden = true
animationStart = true
}

最佳答案

你在哪里调用函数animation()

我觉得viewDidLoad应该是这样的

override func viewDidLoad() {
super.viewDidLoad()
//remove root view controller navigation bar
self.navigationController?.navigationBar.isHidden = true
animationStart = true
animation() //call animation
}

关于ios - 动画在 Swift 3 Xcode 8.1 中没有动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41555713/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com