Image after String in UI
psyFi last edited by
I'm making a today widget that shows a number (unknown number of digits) with an image beside the number.
Using frames, I can place the ImageView next to my Label, but I'd like the image to hug the contents of the label.
I've tried adding the image view as a subview to the label, using flex, and hard coded paths. Can anyone please help me out on this?
If I know how to get the width in pixels of the number string, I can adjust the frame accordingly, but I don't know how to do that either.
cvp last edited by
@psyFi Try ui.measure_string
mikael last edited by
size_to_fiton the label. Your enclosing view probably needs to be custom so that you can implement the
layoutmethod where you first size the label and then position the image. If your text changes a lot, you might also implement a
textproperty for the enclosing class, where you can set the label text and then call
size_to_fiton the enclosing view, or just the repositioning code directly.