我有兩個UIImageViews。一個是'前線',另一個是'後退'。 我試圖實現它,所以當你點擊'返回'它將觸發動畫並翻轉卡。iOS - 卡片翻轉動畫
動畫效果很好。但它動畫整個頁面,我不想要。我只想要UIImageView
翻轉。我看不到我做錯了什麼。可能很明顯。
@IBOutlet weak var answerImageViewer: UIImageView?
@IBOutlet weak var backAnswerImageViewer: UIImageView?
override func viewDidLoad() {
super.viewDidLoad()
startNewGame()
retrieveNewQuestion()
setupBannerMessage()
customPlayButtons()
let tapGesture = UITapGestureRecognizer(target: self, action: Selector("tap"))
tapGesture.numberOfTapsRequired = 1
backAnswerImageViewer?.addGestureRecognizer(tapGesture)
backAnswerImageViewer?.userInteractionEnabled = true
}
var showingBack = true
func tap(){
if showingBack{
UIView.transitionFromView(self.backAnswerImageViewer!, toView: self.answerImageViewer!, duration: 1, options: UIViewAnimationOptions.TransitionFlipFromRight, completion: nil)
backAnswerImageViewer?.hidden = true
answerImageViewer?.hidden = false
showingBack = false
}
else {
showingBack = true
UIView.transitionFromView(self.answerImageViewer!, toView: self.backAnswerImageViewer!, duration: 1, options: UIViewAnimationOptions.TransitionFlipFromRight, completion: nil)
backAnswerImageViewer?.hidden = false
answerImageViewer?.hidden = true
}
}
你是什麼意思動畫整個頁面?你能提供一個截圖嗎? – wint
而不是隻是UIImageView翻轉,視圖控制器翻轉而不是 –