views:

113

answers:

1

I have a UILabel with right-aligned text that may vary from between three to seven characters in length. I am trying to anchor a button to the left of this text so that when the length of the text increases, the button will stay the same distance from the left of the label.

Is there an anchor setting in Interface Builder, or does it require a code-level solution (e.g. setting the button's x position according to the width of the label)?

+1  A: 

You need to do this in code. Interface builder is not build for runtime calculations.

To calculate the width of you text you can use NSString's sizeWithFont: method.

gcamp