2015-08-25 33 views
-1

如何動畫只有UIImageView的內容?如果圖像視圖居中在屏幕中間,您如何將圖像設置爲從左側滑入,但僅在圖像視圖的框架內顯示?如何只動畫UIImageView的內容

就好像你正在用窗戶看着牆壁,有人在旁邊走過。直到他們在窗口的框架中,才能看到它們。

下面的代碼當然不會這樣做。我前幾天輕鬆地將它刪除了,現在我不記得我是如何做到的。這很簡單,但現在它讓我發瘋。

 self.lockImages[button.tag].center.x -= self.lockImages[button.tag].bounds.width 


     UIView.animateWithDuration(2.0, delay: 0.0, usingSpringWithDamping: 0.5, initialSpringVelocity: 1.0, options: nil, animations: {() -> Void in 

      self.lockImages[button.tag].center.x += self.lockImages[button.tag].bounds.maxX 


     }, completion: { (Bool) -> Void in 


     }) 

回答

0

UIImageViewUIView一個子類,繼承.clipsToBounds()方法,這將產生期望的效果。