自定义键盘iOS 8中的UIActivityIndi​​catorView没有动画swift

时间:2014-10-09 10:55:33

标签: swift ios8 custom-keyboard

我在swift中做了一个iOS 8自定义键盘,我在视图中添加了一个UIActivityIndi​​catorView,问题是我可以看到它,但是没有旋转,它是静态的,这是代码:

@IBOutlet var menuLabel: UILabel!

override func viewDidLoad() {
    super.viewDidLoad()
    self.load_indicator = UIActivityIndicatorView(frame: CGRectMake(0,0, 50, 50)) as UIActivityIndicatorView
    self.load_indicator.hidesWhenStopped = true
    self.load_indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
    self.view.addSubview(self.load_indicator)
}

override func viewDidAppear(animated: Bool) {
    super.viewDidAppear(animated)

    dispatch_async(dispatch_get_main_queue(), {
        self.load_indicator.startAnimating()
        })
}

出现加载指示,但它是静态的,我该怎么做?

1 个答案:

答案 0 :(得分:0)

load_indicator = UIActivityIndicatorView(frame: CGRectMake(0,0, 50, 50))
load_indicator.hidesWhenStopped = true
load_indicator.startAnimating()
load_indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
view.addSubview(load_indicator)  

你需要用

开始动画
load_indicator.startAnimating()

您可能也对此课感兴趣:https://github.com/goktugyil/CozyLoadingActivity