ArgenBarbie
ArgenBarbie

Reputation: 641

How to animate UITableView to slide up when showing the bottom cell?

I have a tableview and its bottom cell is special. Every time the table reloads, I want the bottom cell to slide up and the upper part of the table seems to be pushed up.

Like this: enter image description here

How can I implement this animation? Thanks!

Upvotes: 0

Views: 236

Answers (1)

nighttalker
nighttalker

Reputation: 946

You can tell the tableView to scroll to a certain row with animation. If that cell is last, just call this after reload:

let scrollToIndexPath = IndexPath(row: numberOfRows - 1, section: 0)
tableView.scrollToRow(at: scrollToIndexPath, at: .bottom, animated: true)

.bottom means you want to scroll to the bottom of the visible tableView.

Upvotes: 1

Related Questions