2016-05-12 35 views
0

我試圖在Swift中的動畫完成塊中執行一個segue。然而,賽格需要很長時間(大約10秒)才能完成,我不知道爲什麼。下面的代碼:在動畫需要很長時間之後執行segue

override func viewDidAppear(animated: Bool) { 
     super.viewDidAppear(animated) 

     imageViewAnimated.startAnimating() 


     if label.center != CGPoint(x:50, y:10) { 

      UIView.animateWithDuration(2.0, delay: 0.0, usingSpringWithDamping: 0.0, initialSpringVelocity: 0.0, options: .CurveEaseOut, animations: {() -> Void in 
       self.label.center = self.view.center 

       }, completion: nil) 

      UIView.animateWithDuration(0.5, delay: 0.0, usingSpringWithDamping: 0.0, initialSpringVelocity: 0.0, options: .CurveEaseOut, animations: {() -> Void in 
       self.label.alpha = 0.0 

       }, completion: { finished in 

        self.poof.alpha = 1.0 
        self.performSegueWithIdentifier("backSegue", sender: nil) 
      }) 
     } 
    } 
+0

是加載大量數據的新的看法? – milesper

+0

新的視圖不過是一個文本框和按鈕,但舊視圖中有很多大圖像被加載到它中。 – Bailey

+0

爲什麼一出現viewservler就離開它? – milesper

回答

0
override func viewDidAppear(animated: Bool) { 
      super.viewDidAppear(animated) 

      imageViewAnimated.startAnimating() 


      if label.center != CGPoint(x:50, y:10) { 

       UIView.animateWithDuration(2.0, delay: 0.0, usingSpringWithDamping: 0.0, initialSpringVelocity: 0.0, options: .CurveEaseOut, animations: {() -> Void in 
        self.label.center = self.view.center 

        }, completion: nil) 

       UIView.animateWithDuration(0.5, delay: 0.0, usingSpringWithDamping: 0.0, initialSpringVelocity: 0.0, options: .CurveEaseOut, animations: {() -> Void in 
        self.label.alpha = 0.0 

        }, completion: { finished in 

         self.poof.alpha = 1.0 
         dispatch_async(dispatch_get_main_queue(),{ 
          self.performSegueWithIdentifier("backSegue", sender: nil) 
         }) 
       }) 
      } 
     } 
相關問題