2016-01-25 54 views
0

我使用一個簡單的動畫向下滑動一個小視圖(該視圖包含一些標籤和一個imageView)。 動畫可以工作,但是當我嘗試設置標籤和imageView的內容時,視圖消失。Swift UIView.animateWithDuration在加載內容時消失

任何幫助?

UIView.animateWithDuration(1, delay: 0, 
       usingSpringWithDamping: springDamping, 
       initialSpringVelocity: velocity, options: option!, animations: { 
        self.sliderUserInfo.frame.origin = self.sliderUserInfoPosition 
       }, completion: {finished in 
        if finished { 
         self.loadContentView() 
        } 
      }) 

回答

0

修改代碼爲:

var newFrame = self.sliderUserInfo.frame 
    newFrame.origin = self.sliderUserInfoPosition 
    UIView.animateWithDuration(1, delay: 0, 
     usingSpringWithDamping: springDamping, 
     initialSpringVelocity: velocity, options: option!, animations: { 
      self.sliderUserInfo.frame = newFrame 
     }, completion: {finished in 
      if finished { 
       self.loadContentView() 
      } 
    }) 
+0

這不是更好。僅供參考,所有的UIViews都使用自動佈局.. – Stan92