一些 UILabel 带有一个大文本

发布于 2024-12-21 11:39:16 字数 215 浏览 1 评论 0原文

我有一个很大的 NSString ,里面有很多符号,我想用它制作一些 UILabels 。 例如: 我的文字:我来自莫斯科。我的昵称是 itruf。 结果: 第一个标签:我来自莫斯科。 第二个标签:我的昵称是 第三个标签:itruf。

所有 UILabel 必须有一种大小和字体(我想进行分页,如 bookmate 或 ibooks)。

PS:我想用我的标签制作 NSArray 。

I have one big NSString with a lot of symbols and I want to make some UILabels with it.
For example:
My text: I am from Moscow. My nickname is itruf.
Result:
First label: I am from Moscow.
Second label: My nickname is
Third label: itruf.

All UILabel must have one size and font (I want to make paging, like bookmate or ibooks).

PS: I want to make NSArray with my labels.

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

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

发布评论

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

评论(2

我不是你的备胎 2024-12-28 11:39:16
NSString *list = @"I am from Moscow. My nickname is itruf.";

NSArray *listItems = [list componentsSeparatedByString:@"."];
myCity.text = [listItems objectAtIndex:0];
myName.text = [listItems objectAtIndex:1];

其中 myCity 和 myName 是您的标签。

NSString *list = @"I am from Moscow. My nickname is itruf.";

NSArray *listItems = [list componentsSeparatedByString:@"."];
myCity.text = [listItems objectAtIndex:0];
myName.text = [listItems objectAtIndex:1];

Where myCity and myName is your labels.

淡忘如思 2024-12-28 11:39:16

或者如果你想调整标签高度,

CGRect rect = CGRectMake(20, 10, 190, 1000);
self.label.numberOfLines = 0;
self.label.frame = rect;
[self.label sizeToFit];

那么它会自动从 1000 下降到合理的高度。

Or if you want to adjust your label height,

CGRect rect = CGRectMake(20, 10, 190, 1000);
self.label.numberOfLines = 0;
self.label.frame = rect;
[self.label sizeToFit];

Then it'll automatically come down from 1000 to the reasonable height.

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