let screenBound = UIScreen.main.bounds let progressIndc = UIActivityIndicatorVIEw() progressIndc.frame = CGRect(x: screenBound.wIDth / 2 - 10,y: screenBound.height / 2 - 10,wIDth: 20,height: 20) progressIndc.hIDesWhenStopped = true progressIndc.color = UIcolor.gray progressIndc.activityIndicatorVIEwStyle = UIActivityIndicatorVIEwStyle.gray // self.vIEw is scroll vIEw self.vIEw.addSubvIEw(progressIndc) progressIndc.startAnimating()
但它显示在iPhone 7的顶部附近.应该是正确的方法?我还可以使用进度指示器执行阻止d出对话框.
解决方法 如果要在滚动时将指示器视图保持在屏幕中心,可以将叠加视图添加到当前最顶层的UIWindow,然后将指示器视图添加到叠加视图:guard let topWindow = UIApplication.shared.windows.last else {return}let overlayVIEw = UIVIEw(frame: topWindow.bounds)overlayVIEw.backgroundcolor = UIcolor.cleartopWindow.addSubvIEw(overlayVIEw)let hudVIEw = UIActivityIndicatorVIEw()hudVIEw.bounds = CGRect(x: 0,y: 0,height: 20)overlayVIEw.addSubvIEw(hudVIEw)hudVIEw.center = overlayVIEw.center
你应该在最顶层的UIVIEwController视图附加在顶部的UIWindow之后执行此 *** 作,例如,在vIEwDIDAppearmethod中.
总结以上是内存溢出为你收集整理的iOS – 在屏幕中央而不是视图中显示进度指示器全部内容,希望文章能够帮你解决iOS – 在屏幕中央而不是视图中显示进度指示器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)