我想用activity indicator
文件在TableView
中显示NIB/XIB
,但它不在中间,而是放在右侧
我愿意:
override func viewDidLoad() {
super.viewDidLoad()
let actInd: UIActivityIndicatorView = UIActivityIndicatorView()
actInd.frame = CGRect(x: 0.0, y: 0.0, width: 40.0, height: 40.0)
actInd.center = self.view.center
actInd.hidesWhenStopped = true
actInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.whiteLarge
self.view.addSubview(actInd)
actInd.startAnimating()
}
最佳答案
let actInd: UIActivityIndicatorView = UIActivityIndicatorView()
override func viewDidLoad() {
super.viewDidLoad()
actInd.frame = CGRect(x: 0.0, y: 0.0, width: 40.0, height: 40.0)
actInd.hidesWhenStopped = true
actInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.whiteLarge
self.view.addSubview(actInd)
actInd.startAnimating()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
actInd.center = self.view.center
}
/* Following two functions are acceptable also.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
actInd.center = self.view.center
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
actInd.center = self.view.center
}
*/