我在CABasicAnimation
的{{1}}方法中创建awakeFromNib
,如下所示:
UITableViewCell
但是当我使用class TableviewCell: UITableViewCell {
@IBOutlet weak var viewToAnimate: UIView!
override func awakeFromNib() {
super.awakeFromNib()
let hoverBasicAnimation = CABasicAnimation(keyPath: "position")
hoverBasicAnimation.isAdditive = true
hoverBasicAnimation.fromValue = NSValue(cgPoint: CGPoint(x: 0, y:self.viewToAnimate.frame.origin.y))
hoverBasicAnimation.toValue = NSValue(cgPoint: CGPoint(x:0, y: self.viewToAnimate.frame.origin.y + 30.0))
hoverBasicAnimation.autoreverses = true
hoverBasicAnimation.duration = 5
hoverBasicAnimation.repeatCount = Float.infinity
self.viewToAnimate.layer.add(hoverBasicAnimation, forKey: "hover animation")
}
}
进行“拉动刷新”重新加载UITableView
时,动画停止。
如何在刷新/重新加载UIRefreshControl
时阻止动画停止?