I have a UIButton object that has a title that's determined at runtime. The title might be multi-line, so I want to increase the UIButton object's height to match its title label's height. I do not want to create a UIButton subclass, as I've read that it is not good behavior. Which is why I don't understand why the answers from this question (which would otherwise solve this issue) all involve subclassing UIButton. This answer also involves subclassing UIButton as well.
I'm using auto-layout on 10.x and sizeToFit doesn't seem to do anything. I've also tried calling invalidateIntrinsicContentSize and that also doesn't do anything. I've sent content hugging to 1 and content compression to 999 and that also doesn't work.
Has Apple provided any official solution for automatically resizing a UIButton's height based on its title label? All of the similar questions linked to this one give different solutions, and a lot of them involve things that seem hacky (subclassing UIButton, adding a height constraint for the button to be updated when the title changes, manually re-setting the frame of the button).