Auto layout button text that can resize both left and right from the centre?

I know with auto layout button text can be aligned left and grow to the right, or aligned right and grow left. Is it possible for button text to grow from the centre, left and right?

Yep, easy. But it’s not about button, but the parent frame where the button sits

1 Like

I think I sort of tried that. I have text inside a frame inside an auto layout. If I have the frame spacing mode set to ‘space between’ the text will from the centre (exactly what I want) but my rectangle won’t grow with the text.

1 Like

Auto Layout Frame set to Hug Content (= resize with different text)

Parent frame:
Auto Layout with Alignment top center or center center

If the parent frame doesn’t utilize Auto Layout you’ll need to adjust the constraints of the Button and set left and right to center. Change the button position and align it to the center as well.

The alignment of the text doesn’t matter here by the way.


Did some more tinkering. This worked! :heart_eyes:

1 Like

Spacing mode doesn’t need to be set to “space between” if you’re using one element only.
“Packed” is the more correct way to do it. If theres only one element the result is the same though. :smile:

1 Like

The only problem with setting to ‘packed’ means the text will only grow to the right :slightly_smiling_face: whatever gets the job done ay! :hammer_and_wrench: :smile:

1 Like