开发者

Anchor UIButton to the left of a UILabel

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 开发者_如何学Goincreases, 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)?


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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜