I am trying to add animations in tableview cells and the animations are working fine. But when i try to stop the scroll of tableview by tapping its not stopping. Usually in a scrolling tableview if we tap of screen the scroll would stop. But when i add these animations thats not working. below is the code i use for animations
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
}
}
Note:
This is normal behavior for animations using one of the animateWithDuration... method. Still if you want user interaction during the animation you can try like Below i have shown.
Simply you need to try like this :
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)
}
Hope it will help to you.
The main thing you’re hitting here is that UIView animations, by default, disable touches on the animating views while an animation is in progress. You can change that behavior by switching to the +animateWithDuration:options:delay:animations:completion:
method and adding the UIViewAnimationOptions value AllowUserInteraction
, like this:
UIView.animateWithDuration(0.5, delay:0, options:[.AllowUserInteraction], animations:{ () -> Void in
cell.layer.transform = CATransform3DIdentity
}, completion:nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With