0
我有一个UITableView从左到右检测滑动。我想在用户通过改变宽度约束的常量进行滑动时显示一个删除按钮。但不管我尝试做什么,按钮都不会动画或改变宽度。我可以让按钮显示约束更改的唯一方法是重新加载行。UITableViewCell动画按钮约束
这就是我现在所拥有的。我看到的每个答案都包含这种动画约束的方法。
func TableViewSwipeRight(gesture: UIGestureRecognizer)
{
let point = gesture.location(in: favoriteStationsTableview)
let indexPath = favoriteStationsTableview.indexPathForRow(at: point)
if let indexPath = indexPath {
if let favoriteCell = favoriteStationsTableview.dequeueReusableCell(withIdentifier: FavoriteCell.GetReuseId(), for: indexPath) as? FavoriteCell {
self.view.layoutIfNeeded()
favoriteCell.deleteBtnConstraint.constant = 50
UIView.animate(withDuration: 0.5, animations: {
self.view.layoutIfNeeded()
})
}
}
}
谢谢!这工作 – Arthur