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

Button's title font set in Storyboard/IB will be discarded #1230

Closed
mohpor opened this issue May 18, 2019 · 7 comments
Closed

Button's title font set in Storyboard/IB will be discarded #1230

mohpor opened this issue May 18, 2019 · 7 comments

Comments

@mohpor
Copy link
Contributor

mohpor commented May 18, 2019

Hi,

Material 3.x (and Theming to be more specific), discards font's set on Buttons in IB.

titleLabel?.font = Theme.font.regular(with: fontSize)

this line will override the button's font, regardless of you opting out of theming.

I guess it should check to see if Theming (globally) is enabled before changing values.

e.g.:

if Theme.isEnabled {
   titleLabel?.font = Theme.font.regular(with: fontSize)
}

For now, the workaround is to set button's font in code.

@mohpor mohpor changed the title title font set in Storyboard/IB will be discarded Button's title font set in Storyboard/IB will be discarded May 18, 2019
@OrkhanAlikhanov
Copy link
Contributor

OrkhanAlikhanov commented May 19, 2019

Hmm, titleLabel?.font = has always been around setting font to roboto, we've just updated it to use Theme.font instead of RobotoFont directly.

If we add Theme.isEnabled check it then next time a dev updates Material will end up seeing different font if it hasn't been changed previously in code.

I think we may check if font is set by user by comparing current one with default one:

let defaultButtonFont = UIFont.systemFont(ofSize: UIFont.buttonFontSize)
if titleLabel?.font == defaultButtonFont {
    titleLabel?.font = Theme.font.regular(with: fontSize)
}

@mohpor Can you please try above code and see if it works for you?

@mohpor
Copy link
Contributor Author

mohpor commented May 19, 2019

Then it must be something else that is triggering the font update.

I have a rather large project that has many many Button instants, after updating to Material 3.x, all of those which rely on IB for font description now have lost the font.

I already have a workaround, but due to the vast amount of revision and coding effort, I had to revert back to 2.16.4

If we add Theme.isEnabled check it then next time a dev updates Material will end up seeing different font if it hasn't been changed previously in code.

this is what has happened to me unfortunately.

@OrkhanAlikhanov
Copy link
Contributor

Ahh, I am mistaken. The line was added by me in cf36b57 It was not there before.

@OrkhanAlikhanov
Copy link
Contributor

The reason why I added it, I believe, was that @DanielDahan had been changing font to RobotoFont after creating a button throughout the sample projects. I just wanted to eliminate it by setting it in the library itself which unfortunately seems to a breaking change for storyboard users. @DanielDahan I think we should remove the line back. What do you think?

@OrkhanAlikhanov
Copy link
Contributor

btw, thank you for reporting this @mohpor 💪

@OrkhanAlikhanov
Copy link
Contributor

Hey @mohpor! You can try #1231 to see if it fixes your issue.

@daniel-jonathan
Copy link
Member

Hi @mohpor please find the latest release with the above fixes here https://github.com/CosmicMind/Material/releases/tag/3.1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants