Skip to content
This repository has been archived by the owner on Aug 24, 2020. It is now read-only.

heightForFooterInSection does not take font into account #25

Open
snyamathi opened this issue Nov 8, 2015 · 1 comment
Open

heightForFooterInSection does not take font into account #25

snyamathi opened this issue Nov 8, 2015 · 1 comment
Labels
Milestone

Comments

@snyamathi
Copy link

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
Copy link
Owner

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.

@davdroman davdroman added the bug label Nov 27, 2015
@davdroman davdroman added this to the 4.0.0 milestone Nov 27, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants