我試圖使用transitionWithVIew
動畫UIImageView中的圖像更改動畫。圖像發生變化,但似乎沒有動畫效果。不知道爲什麼會這樣。UIView.transitionWithView不動畫
這裏是我的代碼:
func changeBackgroundAtIndex(index : Int) {
switch index {
case 0:
animateChangeWithImage(MLStyleKit.imageOfAboutMe)
case 1:
animateChangeWithImage(MLStyleKit.imageOfProjects)
case 2:
animateChangeWithImage(MLStyleKit.imageOfSkills)
case 3:
animateChangeWithImage(MLStyleKit.imageOfEducation)
case 4:
animateChangeWithImage(MLStyleKit.imageOfTheFuture)
default:
animateChangeWithImage(MLStyleKit.imageOfAboutMe)
}
}
func animateChangeWithImage(image : UIImage) {
UIView.transitionWithView(backgroundImageView, duration: 0.4, options: UIViewAnimationOptions.TransitionCrossDissolve, animations: {() -> Void in
self.backgroundImageView.image = image
}, completion: nil)
}
任何想法?謝謝:)
此功能可以與self.view正常工作。 – Rahul
請參閱此另一個解決方案:http://stackoverflow.com/questions/7616655/uiview-transitionwithview-doesnt-work – Rahul
@Rahul使用'self.View'而不是'self.backgroundImageView'不是爲我修復 – mlevi