我有一個應用於它的輕擊手勢的視圖。當手指擡起時,我想讓視線「縮小」,並且讓視圖恢復正常。我試圖用UIGestureRecognizerState
來達到這個目的,但它不起作用。只有當我移開手指並且不回去時,視圖纔會縮小。這裏是我的代碼:點擊手勢與UIGestureRecognizerState不起作用
@IBAction func shareButton(sender: AnyObject) {
if sender.state == UIGestureRecognizerState.Changed {
UIView.animateWithDuration(0.1, delay: 0.0, usingSpringWithDamping: 0.4, initialSpringVelocity: 0.4, options: nil, animations: {
self.shareButton.transform = CGAffineTransformMakeScale(0.9, 0.9)
}, completion: nil)
} else if sender.state == UIGestureRecognizerState.Ended {
UIView.animateWithDuration(0.1, delay: 0.0, usingSpringWithDamping: 0.4, initialSpringVelocity: 0.4, options: nil, animations: {
self.shareButton.transform = CGAffineTransformMakeScale(0.7, 0.7)
}, completion: nil)
}
}
不只是與按鈕圖像UIControlEventTouchDown? – mlevi 2014-10-06 05:25:48