Open snyamathi opened 8 years ago
Hi @snyamathi.
Footer titles with custom fonts are definitely a nightmare. The thing is UITableView isn't smart enough to adjust the footer to any font that isn't the default one (even changing the font involves a hack in the first place!).
So knowing all this, I don't see anything wrong with assuming a certain fixed padding for the label and adjusting it the hardcoded way as a workaround.
As a first thought, a prettier fix I can think of would be to calculate the difference between the default font's height and the new font's height and subtract that difference to the label's vertical position, which is still kinda hacky, but not that much in terms of how bad UITableView handles the situation by default.
When I set a footerTitleFont (eg
section.footerTitleFont = UIFont(name: "Avenir-Book", size: 9)
), that font is not taken into account (here. This is particularly noticeable when you have a string which is a different number of lines with the applied font vs the default font. Example:Default font:
Custom font (observed):
I made some changes in a fork to take the font into consideration, but I don't really like having to assume the padding around the textLabel (observed to be 16 on the left and right and 7 on the top and bottom). I'll have a think about how to remove that without making things too complicated, though perhaps you have a better idea.
Custom font (expected):