我想創建一個函數,以便我可以輕鬆實現並對正在使用的加載動畫進行修改。我不知道如何將我需要的所有東西都正確地返回並顯示出來。下面是我用來創建它的代碼:返回動畫功能
let x = (self.view.frame.size.width/2)
let y = (self.view.frame.size.height/2)
self.loadingUI = NVActivityIndicatorView(frame: CGRectMake(x, y, 100, 100))
self.loadingUI.center = CGPointMake(view.frame.size.width/2,
view.frame.size.height/2)
self.loadingBackground.backgroundColor = UIColor.lightGrayColor()
self.loadingBackground.frame = CGRectMake(0, 0, 150, 150)
self.loadingBackground.center = (self.navigationController?.view.center)!
self.loadingBackground.layer.cornerRadius = 5
self.loadingBackground.layer.opacity = 0.5
self.navigationController?.view.addSubview(loadingBackground)
self.navigationController?.view.addSubview(loadingUI)
self.loadingUI.type = .BallRotateChase
self.loadingUI.color = UIColor.whiteColor()
self.loadingUI.startAnimation()
是否有可能寫入可能會創建這樣我可以在整個應用程序就多時間的函數?這個自定義應用程序的大部分內容都在導航控制器中。
究竟是你在創建什麼? loadingUI和loadingBackground? –
是的,這是正確的。這就是我需要創建出現在屏幕上。 – trever