I have a UIButton that I want to resize to fit whatever text is inside it. It has a set width of 280, but the text should wrap to the next line(s) and extend the height of the button as needed.
I've set line breaks to Word Wrap and tried sizeToFit but that only makes the button go wider, not vertical.
Make sure you set the text on your button this way:
[myButton setTitle:@"my title" forState:UIControlStateNormal];
... and [myButton sizeToFit]
should work like a charm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With