我正在使用这个库https://github.com/PiXeL16/RevealingSplashView添加像闪屏这样的东西。
我从Internet上获取数据时使用的是RevealingSplashView。但不幸的是,如果请求时间太长,它会使应用程序像冻结一样。所以我想在屏幕的底部中心或RevealingSplashView中的其他地方添加类似UIActivityIndicatorView的内容。
var revealingSplashView = RevealingSplashView(iconImage: UIImage(named: "loadscreenLogo")!,iconInitialSize: CGSize(width: 110, height: 110), backgroundColor: AppColor.mainYellow.getUIColor())
revealingSplashView.addSubview(UIActivityIndicatorView())
但它没有显示任何东西
这是我将如何做到这一点。您需要一个UIActivityIndicatorView实例,而不是使用类本身。
//loading indicator
let indicator:UIActivityIndicatorView = UIActivityIndicatorView (activityIndicatorStyle: UIActivityIndicatorViewStyle.gray)
然后加载指示器 - 这是在屏幕的中心,但我们可以使用.center CGPoint轻松更改它。您可以使用.frame更大的指标。
fileprivate func loading(){
indicator.color = UIColor.gray
indicator.frame = CGRect(x: 0.0, y: 0.0, width: 15.0, height: 15.0)
indicator.center = CGPoint(x: revealingSplashView center.x, y: revealingSplashView.center.y - (navigationController?.navigationBar.frame.height)! )
revealingSplashView.addSubview(indicator)
indicator.bringSubview(toFront: self.view)
indicator.startAnimating()
}
当你完成了
self.indicator.stopAnimating()
并删除指标