簡體   English   中英

輕觸單元格時的TableView動畫

[英]TableView animation when the cell is tapped

當用戶將手指放在上面時,我想為tableView單元設置動畫,如該圖像 在此處輸入圖片說明

當用戶停止按下時,單元格恢復為原始大小(我的tableView未使用自定義單元格,而是默認的UItableViewCell)。 我環顧四周,找到了一些教程或有用的東西,但是一無所獲,有人可以告訴我我該怎么辦?

您可以這樣做:

UITableViewCell的觸地事件:

UIView.animateWithDuration(0.2, delay: 0.1, usingSpringWithDamping: 0.9, initialSpringVelocity: 5, options: [],animations: {
            self.contentView.transform = CGAffineTransformMakeScale(0.95, 0.95)
            }, completion: { finished in

        })

並在UITableViewCell的Touch Up事件上:

UIView.animateWithDuration(0.2, delay: 0, usingSpringWithDamping: 0.9, initialSpringVelocity: 5, options: .CurveEaseIn,animations: {
            self.contentView.transform = CGAffineTransformMakeScale(1, 1)
            },completion: { finished in

        })

希望這會幫助你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM