0
我想旋轉一個ImageView和哪個工作,但是當我從另一個屏幕上加載該屏幕動畫不起作用。動畫不起作用?
class LoadingRequestViewController: UIViewController ,UICollectionViewDelegate,GMSMapViewDelegate, CLLocationManagerDelegate {
//UI OutletControls
@IBOutlet weak var loadingImg: UIImageView!
@IBOutlet var mapView: GMSMapView!
@IBOutlet weak var containerView: UIView!
//UI OutletControls
override func viewDidLoad() {
super.viewDidLoad()
loadingImg.startRotating()
}
func TimerStoppedTrue() {
TimerStopped = true
NSLog("TimerStopped\(TimerStopped)")
}
@IBAction func CancelHireAction(sender: AnyObject) {
self.timer.invalidate()
self.CancelHire(self.HireID)
}
}
extension UIView {
func startRotating(duration: Double = 1) {
let kAnimationKey = "rotation"
if self.layer.animationForKey(kAnimationKey) == nil {
let animate = CABasicAnimation(keyPath: "transform.rotation")
animate.duration = duration
animate.repeatCount = Float.infinity
animate.fromValue = 0.0
animate.toValue = Float(M_PI * 2.0)
self.layer.addAnimation(animate, forKey: kAnimationKey)
}
}
func stopRotating() {
let kAnimationKey = "rotation"
if self.layer.animationForKey(kAnimationKey) != nil {
self.layer.removeAnimationForKey(kAnimationKey)
}
}
}
當我打電話LoadingRequestViewController像下面的動畫不work.But單獨它的工作。
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("LoadingSTBID") as! LoadingRequestViewController
self.presentViewController(vc, animated: true, completion: nil)