UIEmptyState icon indicating copy to clipboard operation
UIEmptyState copied to clipboard

Button does not resize to fit text

Open im-jersh opened this issue 7 years ago • 4 comments

It seems like setting the font size to some arbitrary value depending on the device type will cause the action button's title to be truncated.

Here's an 8 Plus with the font size set to 17pt: simulator screen shot - iphone 8 plus - 2018-02-22 at 14 22 37

And the same device with the font size set to 16pt: simulator screen shot - iphone 8 plus - 2018-02-22 at 14 23 07

im-jersh avatar Feb 22 '18 20:02 im-jersh

You need to adjust the buttons size to fit the font, you can do this with the data source methods.

luispadron avatar Feb 22 '18 21:02 luispadron

But even the documentation says the default implementation should size the button to fit the title PLUS some padding yet this is not the result I'm seeing. Don't mind sizing the button myself, just think the docs should be consistent with that requirement if it is in fact a requirement.

screen shot 2018-02-22 at 3 28 12 pm

im-jersh avatar Feb 22 '18 21:02 im-jersh

Also, if simulate padding by adding blank spaces to the beginning and end of my button title, then the issue is resolved. Definitely think this is issue is a bug that needs to be addressed internally. Can try to track it down later and submit a PR.

im-jersh avatar Feb 22 '18 21:02 im-jersh

You're right, my bad. This does seem like a bug that should be looked into.

The code which handles this constraint for the button:

let size = buttonSize ?? self.buttonTitle?.size() ??
                    self.buttonImage?.size ??
                    CGSize(width: 0, height: 0)
                
button.heightAnchor.constraint(equalToConstant: size.height).isActive = true
button.widthAnchor.constraint(equalToConstant: size.width).isActive = true

I don't have time currently to look at this, but if you want to take a look and submit a PR that would be great!

luispadron avatar Feb 22 '18 21:02 luispadron