Skip to content

Facebook liked cell, provide the functionality of dynamically changing the height of UITableViewCell with animation.

License

Notifications You must be signed in to change notification settings

Lerist/Swift-CellAnimation

 
 

Repository files navigation

Swift Cell-Height-Animation

Inspired by Facebook UITableview cell animation, which is the "see more" button on the cell that could dynamically change the cell height with animation.

Requirements

  • Swift 3
  • iOS 8.0+

Demo

Also I added the transition animation when tapped imageView and the algorithm that displays the images on the cell.

Implementation

These two lines are the most important to accomplish the height changing animation effect. (I spent a lot of time reserching, but I never thought the solution will be rather simple)

tableView.beginUpdates()
tableView.endUpdate()

This is also denoted as a side effect of uitableview. With this effect, we could then add animations for these two methods.

UIView.animate(withDuration: 0.7, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.3, animations: {
            self.tableView?.beginUpdates()
            self.tableView?.endUpdates()
        }, 
        completion: nil)

The fixed-height view with higher priority will not get animated, only the one with lowest priority will get animated.

Author

Marvin Zhan, marvinzhanmonster@gmail.com, Wechat : mononster

Currently University of Waterloo undergraduate student.

License

MIT

About

Facebook liked cell, provide the functionality of dynamically changing the height of UITableViewCell with animation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%