Skip to content

Instantly share code, notes, and snippets.

@mschmulen
Last active October 13, 2016 16:26
Show Gist options
  • Save mschmulen/9c8434f957701ae83d7f62ce418a6222 to your computer and use it in GitHub Desktop.
Save mschmulen/9c8434f957701ae83d7f62ce418a6222 to your computer and use it in GitHub Desktop.
animate cell
// If you wanted to smooth in the animation of the tableview cell you can do something like this ...
extension SomeTableViewCell : AnimatedTableViewCellProtocol {
func startAnimation() {
//this scales but it could alpha in as well
self.layer.transform = CATransform3DMakeScale(0.75,0.75,1)
UIView.animateWithDuration(0.20, animations: {
self.layer.transform = CATransform3DMakeScale(1,1,1)
})
}
}
// and add the delegate method to call it.
extension SomeTableViewController : UITableViewDelegate {
public func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if let atvc:AnimatedTableViewCellProtocol = cell as? AnimatedTableViewCellProtocol {
atvc.startAnimation()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment