我正在开发Swift中的应用程序。这个应用程序有很多视图,我想在所有视图上放一个UIProgressView
我们可以得到所有情节提要视图的数组吗?
举个例子 :
self.progressBar = UIProgressView(progressViewStyle: .Bar)
self.progressBar?.center = view.center
self.progressBar?.frame = CGRect(x: 0, y: 20, width: view.frame.width, height: CGFloat(1))
self.progressBar?.progress = 1/2
self.progressBar?.trackTintColor = UIColor.lightGrayColor();
self.progressBar?.tintColor = UIColor.redColor();
var arrayViewController : [UIViewController] = [...,...,...]
for controller in arrayViewController {
controller.view.addSubview(self.progressBar)
}
谢谢
伊塞
我假设您真正想要的是如果正在进行某项操作,则在每个视图上显示进度。
有很多方法可以做到这一点(使用委托,NSNotificationCenter等),但是我能想到的最简单的方法就是依靠viewWillAppear
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
// Check if there's an operation in progress and add progressView if relevant
}
对于用户而言,它实际上看起来就像您将进度视图添加到了所有视图。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句