UILabel 及其中的图像

发布于 2024-09-12 13:14:31 字数 1468 浏览 2 评论 0原文

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

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

发布评论

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

评论(3

做个少女永远怀春 2024-09-19 13:14:32

根据您的示例图像,这将是一个自定义对象,您必须将其创建为 UIImage 的子类。或者您可以采取更简单的路线,只需将其作为 Interface Builder 中的视图即可添加为子视图。

子类化 UIImage 的一个示例就像创建一个辅助方法:

@interface UIImage (Labels)
- (UIImage*)toSize:(CGSize)size withLabel:(NSString *)label1 andSecondLabel:(NSString *)label2;
@end

但是您必须自己实现全部绘制。

相反,我可能会说在 Interface Builder 中创建一个视图,该视图具有:

(1) UIImageView

(6) UI标签

,您可以将其用作子视图,然后将它们设置为代码中正常的任何值。

Based on your sample image, this would be a custom object that you would have to create as a subclass of UIImage ..or you could go the easier route just make it as a view in Interface Builder that you add as a subview.

An example of subclassing UIImage would be like creating a helper method:

@interface UIImage (Labels)
- (UIImage*)toSize:(CGSize)size withLabel:(NSString *)label1 andSecondLabel:(NSString *)label2;
@end

but you would have to then implement drawing it all by yourself.

Instead, I would probably say go the route of creating a view in Interface Builder that has:

(1) UIImageView

(6) UILabels

that you can use as a subview and then you'd set them to whatever values like normal in code.

第七度阳光i 2024-09-19 13:14:32

我不确定,但是 Three20 是我在 Iphone 中见过的支持文本的最强大的项目和样式表。您可能想看一下

I am not sure, but Three20 is the most powerful project that I have ever seen in Iphone to support text and stylesheet. You may want to take a look

浮光之海 2024-09-19 13:14:31

最好的方法是为图像的一侧创建一个 UI 标签,然后在图像下方创建另一个 UI 标签 - 然后根据原始文本一次计算第一个标签的高度,一旦你走了超过 UIImageView 的高度后,将其余文本放入底部 UILabel 中。

如果您想要一些示例代码,请给我发送电子邮件至 kigisoftware.com 的 kendall.gelner(我试图寻找一种向您发送电子邮件或 DM 的方式,但在该网站上找不到)。

The best way to go about this is to create a UI Label for the side of the image, then another UI label below the image - then calculate the height of the first label a word at a time from your original text, once you have gone past the height of the UIImageView put the rest of the text in the bottom UILabel.

If you would like some example code, please email me at kendall.gelner AT kigisoftware.com (I tried to look for a way to email or DM you, but could not find one on this site).

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