davdroman / Bohr

Settings screen composing framework
MIT License
1.26k stars 83 forks source link

heightForFooterInSection does not take font into account #25

Open snyamathi opened 8 years ago

snyamathi commented 8 years ago

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:

simulator screen shot nov 8 2015 1 04 09 pm

Custom font (observed):

simulator screen shot nov 8 2015 1 03 58 pm

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):

simulator screen shot nov 8 2015 1 04 41 pm

davdroman commented 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.