marcosgriselli / ViewAnimator

ViewAnimator brings your UI to life with just one line
MIT License
7.3k stars 488 forks source link

No animation for Header and Footer of UICollectionView or UITableView #45

Closed dillidon closed 5 years ago

dillidon commented 6 years ago

Thats all)

dillidon commented 6 years ago

One more thing - views (headers, cells and footers) should be sorted... just caught it in my project...

marcosgriselli commented 5 years ago

After looking into this issue I believe each app should manage their own selection of views that need to be animated. I can't remember if this issue was created before we implemented the animate(views: ... API. It's not that complicated and we can even add a function that grabs all cells and headers in the docs. This is the result of animating headers and footers:

header_footer_animations

And here's a quick example of how views can be picked for animations:

private func viewsToAnimate(in tableView: UITableView) -> [UIView] {
    var views = [UIView]()
    tableView.tableHeaderView.flatMap { views.append($0) }
    tableView.headerView(forSection: 0).flatMap { views.append($0) }
    views.append(contentsOf: tableView.visibleCells)
    tableView.footerView(forSection: 0).flatMap { views.append($0) }
    tableView.tableFooterView.flatMap { views.append($0) }
    return views
}

I know this is super late but I hope this helps someone trying to achieve this result.