Advertisement


Sketch: Object moves relative to another object/text in symbol


Question

How do I make an object automatically move when I change the text preceeding/"attached to" it?

I'm trying to figure out how this default symbol works (gif included below) and replicate it.

When I type " " into the override, the wifi symbol moves next to the reception dots. When I type a longer string in (see gif), the wifi symbol automatically moves accordingly to after the text.

It's as if the wifi symbol is anchored to the END of the "Carrrier" text box (which doesn't have a fixed width), and moves according to how long the text box is. How is this done in Sketch?


Demo of changing text in a symbol with an object moving depending on the lenght of the symbol

The actual artboard doesn't have any special on it:

Artboard layers

Any solutions? Please & thanks!

2016/09/02
1
11
9/2/2016 2:09:00 PM

Accepted Answer

Many thanks to twitter user @kieranpblack !

You must have at least 1px between the text layer and the second layer for it to work. Works on any resizing option, including default stretch!

(Can't even remember if I trialled this before the Sketch 41 update or not? Seems so simple looking at it now.)

2016/11/08
4
11/8/2016 7:31:00 PM