Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypographyButton has wrong height when contentEdgeInsets = .zero #77

Open
mpospese opened this issue Mar 24, 2023 · 0 comments
Open

TypographyButton has wrong height when contentEdgeInsets = .zero #77

mpospese opened this issue Mar 24, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@mpospese
Copy link
Contributor

The height of the typography button (ignoring images) for a single line text label should be:

typography.lineHeight + contentEdgeInsets.top + contentEdgeInsets.bottom

But when contentEdgeInsets == .zero (which is the default) then the height = typography.lineHeight + 12.
It's as if the system then adds in content insets of {6, 0, 6, 0} (unsure of the leading/trailing values but they don't matter to this bug).
If you set the insets to have one value of 0.0000001, even if it's to leading/trailing and top + bottom are both 0, then the button will have the correct height.

This seems to be some sort of bug or behavior in UIButton and it happens on iOS 14+ (all versions we support).

This bug means that by default TypographyButton has the wrong height (12 pts too tall), which is not good.
We might have to resort to a nasty workaround like setting the insets to {0, 0.000001, 0, 0} and maybe also overriding contentEdgeInsets.didSet to intercept .zero and replace it with this alternate "almost zero" version to keep the bug from happening.

@mpospese mpospese added the bug Something isn't working label Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant