如何设置元素的不同宽度 [iPhone-dev]

发布于 2024-10-16 10:19:10 字数 178 浏览 1 评论 0原文

看这张图片:

在此处输入图像描述

用户名是 UIButton。如何在 UIButton(带有用户名)之后放置 UILabel(带有注释文本)?

UIButton 用户名是动态的。我该怎么做?

Look this pic:

enter image description here

The usernames are UIButton. How can I put a UILabel (with the comment text) just after the UIButton (with the username) ?

The UIButton username's is dynamic. How can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

メ斷腸人バ 2024-10-23 10:19:10

这看起来像一个 UITableView,如果是这样的话,您应该子类化 UITableViewCell。如果不是,我会

  1. 考虑使其构建
  2. 一个容器类(或使您的子类 UITableViewCell 使其)包含 UIButton 和 UILabel,并根据标签动态定位文本内的文本按钮的大小(例如,在文本开头添加正确数量的空格)。

That looks like a UITableView, if that's the case you should subclass UITableViewCell. If it isn't, I would

  1. consider making it one
  2. build a container class that (or make your subclassed UITableViewCell such that it) contains both a UIButton and a UILabel and dynamically position the text inside the label according to the size of the button (for instance, adding the right number of spaces to the beginning of the text).
小霸王臭丫头 2024-10-23 10:19:10

您将必须使用核心文本或 Web 视图来实现此目的。确实没有一个超级简单的方法可以做到这一点。根据计算的大小将视图彼此相邻放置很简单,但是要将文本换行为带有嵌入字体样式变化和附件(即图像)的多行,您将必须阅读 Core Text 或在 Web 视图中使用 XHTML。

You're going to have to use Core Text or web views to achieve this. There's really not a super easy way to do this. It's simple enough to place view next to each other based on their calculated sizes, but to have text wrap to multiple lines with embedded font style variations and attachments (i.e., images), you're going to have to read up on Core Text or use XHTML in web views.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文