How do I make a button the exact width as its title?

How do I set the constraints and attributes of a button so that the button is exactly the width of its title?

Accepted Reply

If you mean button width based on it's text property, see: Views with Intrinsic Content Size


If you mean how to defeat margin padding spec'd by auto layout, you may need to do it all in code, instead.

Replies

If you mean button width based on it's text property, see: Views with Intrinsic Content Size


If you mean how to defeat margin padding spec'd by auto layout, you may need to do it all in code, instead.

In IB, in Size Inspector for the button, select, as KMT advised, Intrinsic Size as PlaceHolder.