我希望當我點擊圖像時,另一個圖像出現1或2秒。當我點擊圖像時動畫與圖像
我有兩個圖像(UIImage),一個用於按下,另一個用於未按下。
是這樣的嗎? :
[UIView animateWithDuration: 0.2 delay: 0.0 options: UIViewAnimationOptionAutoreverse animations:^{
pressed.alpha = 1.0;
unPressed.alpha = 0.0;
}completion:^(BOOL finished){
pressed.alpha = 0.0;
unPressed.alpha = 1.0;
}];
但是,我看不到按下的圖像。
編輯:我的問題是ASIGN圖像到UIImageView的,我認爲,因爲當我點擊它出現擠壓的圖像,但隨後未按圖像不會出現
我想任何類似:
[UIView animateWithDuration: 2.0 delay: 0.0 options: UIViewAnimationOptionAutoreverse animations:^{
pressed.alpha = 1.0;
unPressed.alpha = 0.0;
self.imageButton.image = pressed.image;
}completion:^(BOOL finished){
pressed.alpha = 0.0;
unPressed.alpha = 1.0;
self.imageButton.image = unPressed.image;
}];
您已將動畫持續時間設置爲.2,因此在完成前它不會顯示很長時間。如果你想要圖像出現2秒,請將animateWithDuration更改爲2. –
編輯完成後:第二個代碼存在很多問題,但是你想要做什麼?只需讓按鈕圖像顯示2秒鐘,或者您想讓它淡入? –
我想讓它在點擊它時像一個按鈕一樣淡入2秒 – user1911