Search code examples
iosuitableviewios4user-interfacecore-animation

Best way to animate the index of a UITableView?


I have a UITableView with a UIToolbar-like view at the bottom of the screen. I'd like to dynamically animate the toolbar to slide up and down to appear and disappear on the screen when the user takes certain actions on the table data. The problem I'm encountering is that when I animate the toolbar upward, it covers the last few letters of the index.

I'd like to shrink the index size as an animation, along with the toolbar animation. The standard UITableView index functionality doesn't provide us access to this view, just what the view displays, via sectionIndexTitlesForTableView. What's the best way to go about modifying it in such a way?

Example


Solution

  • One way is to animate the entire table view height. This will also prevent your toolbar from covering basically the last cell in case they wanted to do something with it while the toolbar is up.

    If you have a UITableViewController then you might have to move your code into a normal UIViewController.

    Another way is to enumerate through the subviews of your table view and find the section title view that way, though I'm not sure if that would work very well.