In interface builder, holding Command + = will resize a button to fit its text. I was wondering if this was possible to do programmatically before the
For some reason, func sizeToFit() does not work for me. My set up is I am using a button inside a UITableViewCell and I am using auto layout.
What worked for me is:
intrinsicContentSize width because according the this document auto layout is not aware of the intrinsicContentSize. Set the width constraint to the intrinsicContentSize widthHere're two titles from the Debug View Hierachry