Created
April 7, 2017 13:30
-
-
Save alexmx/3bd217b25542fc3dd41fa79cfe2a22c7 to your computer and use it in GitHub Desktop.
Adjust UITableView footer view to fill the whole remaining part of the screen.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prior solutions were additive to the footer height when viewDidLayoutSubviews is called multiple times, causing the footer to become larger than intended. Maybe it worked fine in a UITableView subclass/extension, but not in a UITableViewController (my usage).
Here's the updated logic applied directly in a UITableViewController context:
Of course, make sure your constraints on your footer content are sufficient to keep it pinned to the view's bottom edge as its height expands.
It's also worth noting that the Swift compiler has a time with the lengthy
gapHeight
calculation, which is why I explicitly declared its type. In my usage I have an extensionvar vertical: CGFloat { top + bottom }
on UIEdgeInsets which helps reduce this line a bit more.