这段显示抛硬币的代码有什么问题,我怎样才能在屏幕中央显示这个动画?

What is wrong with this code that shows a flipping coin, also how can I show this animation in the centre of the screen?

 imageView.animationImages = [UIImage(named: "3039668.png")!,    
 UIImage(named: "3039651.png")!]
     imageView.animationDuration = 1.0
     imageView.animationRepeatCount = 10
     imageView.startAnimating()

这是我的代码,我是 swift 的新手,所以请原谅任何愚蠢的错误。如果你能回答问题中的一点,请做

好的,我试过了,它对我有用:

import UIKit
import Foundation

class ViewController: UIViewController {
    var imageView: UIImageView!

    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)

    }

    override func viewDidLoad() {
        super.viewDidLoad()
        let image = UIImage(named: "img1.png")
        imageView = UIImageView(image: image!)
        let uiTap = UITapGestureRecognizer(target: self, action:"myHandle")
        self.view.addGestureRecognizer(uiTap)
        self.view.addSubview(imageView)
    }

    func myHandle(){
        imageView.animationImages = [UIImage(named: "img1.png")!,
        UIImage(named: "img2.png")!]
        imageView.animationDuration = 1.0
        imageView.animationRepeatCount = 10
        imageView.startAnimating()
    }

}

试试看看这个代码和你的有什么不同。