声明:var activityLoadingView:UIActivityIndicatorView!
//显示正在加载的控件
//初始化方式一
activityLoadingView = UIActivityIndicatorView(frame: CGRectMake(self.view.frame.size.width/2-25,self.view.frame.size.height/2,50,50))
self.view.addSubview(activityLoadingView)
activityLoadingView.color = UIColor.redColor()
activityLoadingView.backgroundColor = UIColor.grayColor()
activityLoadingView.alpha = 0.5;
//开始加载
activityLoadingView.startAnimating()
//加载完成
activityLoadingView.stopAnimating()
原文链接:https://www.f2er.com/swift/322882.html