Kal*_*yan 4 iphone uitableview ios swift
我试图在tableview单元格中添加动画,动画工作正常.但是当我试图通过点击它不停止来阻止tableview的滚动.通常在滚动的tableview中,如果我们点击屏幕,滚动就会停止.但是,当我添加这些不起作用的动画时.下面是我用于动画的代码
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
let rotationTransform = CATransform3DScale(CATransform3DIdentity, 0.4, 0.4, 0)
cell.layer.transform = rotationTransform
UIView.animateWithDuration(0.5) { () -> Void in
cell.layer.transform = CATransform3DIdentity
}
}
Run Code Online (Sandbox Code Playgroud)
注意:
这是使用animateWithDuration ...方法之一的动画的正常行为.如果您想在动画期间进行用户交互,您可以尝试下面我已经显示的内容.
只需要尝试这样:
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
let rotationTransform = CATransform3DScale(CATransform3DIdentity, 0.4, 0.4, 0)
cell.layer.transform = rotationTransform
UIView.animateWithDuration(0.5, delay: 0.5, options: UIViewAnimationOptions.AllowUserInteraction, animations: { () -> Void in
cell.layer.transform = CATransform3DIdentity
}, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
希望它对你有所帮助.
归档时间: |
|
查看次数: |
895 次 |
最近记录: |