在 xcode Objective c 中设置第二个标签的动态 x 坐标
我有一个问题,我有两个标签,
1)将包含很长的文本 2)这只是“更多”按钮(链接),
所以我希望当第一个文本结束时,第二个标签从它结束的地方开始。但问题是文本是可变的,所以我找不到任何方法使其动态。 示例
第一行的 文本 “这是第一个标签的文本”
第二行的“更多”文本 在示例中,“测试最佳”“更多”
行是表视图,两个标签由“分隔,所以我想要第二个标签起点,从第一个标签中的文本结束的位置开始,
期待一些解决方案
谢谢和问候!
i have a problem that i have two lables,
1) will contain a long text
2) this will be just More button (link)
so i want that when the first text ends then the second label starts right from where it end. but the problem is that the text is variable so i could not find any way to make it dynamic.
example
text of first row
"this is text of first label" "more"
text of second line
"test best" "more"
in the example the rows are of table view and two lables are separated by " so i want second label starting point from where the text in first lable ends
looking forward for some solution
Thanks & Regards!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NSString
有一些方法可以在使用给定字体显示时计算其大小(例如sizeWithFont:
方法) - 您可以使用它来确定文本宽度并相应地放置更多按钮(someZZZZ参数必须在运行时可用):您可能需要在第一个标签中的文本太长而无法适应屏幕等情况下添加一些验证,但通常此代码应该可以工作。
NSString
has some methods to calculate its size when displaying using given font (e.g.sizeWithFont:
method) - you can use it to determine text width and place your more button accordingly (someZZZZ parameters must be available on runtime):You may need to add some validation for cases when text in first label is too long to fit the screen etc, but in general this code should work.