Skyscanner / SkyFloatingLabelTextField

A beautiful and flexible text field control implementation of "Float Label Pattern". Written in Swift.
Apache License 2.0
4.09k stars 540 forks source link

SkyFloatingLabelTextField doesn't seem to support Dynamic Type #315

Closed tciuro closed 3 years ago

tciuro commented 4 years ago

I have the following code:

    usernameTextField.placeholder = "Username"
    usernameTextField.placeholderFont = UIFont.preferredFont(forTextStyle: .headline)
    usernameTextField.adjustsFontForContentSizeCategory = true
    usernameTextField.title = "Username"
    usernameTextField.titleFont = UIFont.preferredFont(forTextStyle: .headline)
    usernameTextField.adjustsFontForContentSizeCategory = true

I was hoping that either placeholder or title would pick the adjustsFontForContentSizeCategory setting from usernameTextField, but they don't.

It would be great if the text fields (or some API) for placeholder and title were exposed so that we could activate dynamic type.

tciuro commented 4 years ago

I have cloned the project and realized that I can also set the font on placeholderFont:

    usernameTextField.placeholderFont = UIFont.systemFont(ofSize: 20.0)
    usernameTextField.titleFont = UIFont.systemFont(ofSize: 20.0)

What I see is that originally, the text field honors the size. After typing, the title (above the textfield) still continues to honor the font size, but the actual value of the text field is smaller. I cannot find the place in the code where the font size is being overriden.

How/where is the font size of the field changed with a smaller font?

after before

mluisbrown commented 4 years ago

You also need to do:

usernameTextField.titleLabel.adjustsFontForContentSizeCategory = true
k0nserv commented 3 years ago

This is intentional for now and there are no plans to add it.

To clarify I am considering the library done and it wasn't built to accommodate dynamic text. I want to avoid feature creep or big changes which this would be.