Skip to main content
Apr 6, 2023 11:37 AM UTC
Question

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?

This topic has been closed for replies.

6 replies

Pavel_Kiselev
Power Member
Apr 6, 2023 11:43 AM UTC

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

JohnFAuthor
Apr 6, 2023 1:58 PM UTC

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.

dennsi
Active Member
Apr 6, 2023 2:45 PM UTC

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

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.

JohnFAuthor
Apr 6, 2023 3:11 PM UTC

Did some more tinkering. This worked! 😍

dennsi
Active Member
Apr 6, 2023 3:18 PM UTC

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. 😀

JohnFAuthor
Apr 6, 2023 3:30 PM UTC

The only problem with setting to ‘packed’ means the text will only grow to the right 🙂 whatever gets the job done ay! 🛠️ 😀