0

I want to set up a component with a coloured background rectangle and a text, that is ready to be resized in width and also automatically resizes its height based on the length of the text. For now I can only resize the height of the component manually, but would prefer if the component can do this automatically, like HTML does.

I added a constraints top, left&right to the text layer. And constraints top&bottom and left/right to the background layer.

Have a look at the component, the current and expected instance.

Does anyone have a helping hand on this?

enter image description here

boehmatron
  • 713
  • 5
  • 15
  • I’m voting to close this question because it's not about programming and is off-topic for StackOverflow. – Sean Jun 27 '21 at 13:32

1 Answers1

1
  1. Press F then click/drag to create your colored background rectangle.
  2. Press T to create your text layer inside the frame and add constraints to it as follows: top & bottom and left & right.
  3. Select Auto Height in the right-side panel under Text. See detail.
  4. Readjust the width of the text layer to your preferred size and center it inside the frame.
  5. Select the frame layer (parent) which should contain the text layer inside of it (child).
  6. Press Shift A to transform the selected frame into Auto Layout. Notice the icon changed.
  7. Now, to resize, select the text layer and drag ‘n’ drop. See result.
Dragoș
  • 11
  • 1