ios - IOS 中的正字连字词

标签 ios objective-c xcode uilabel

有正字断字的方法吗?

像这样:

NSStiring *string = @"In June 2010 at the World Wide Developers Conference, Apple announced version 4 of Xcode during the Developer Tools State of the Union address.";
UILabel *label = [[UILabel alloc] init];
label.text = string;

如果框架 UILabel 变窄,则获取下一个:

In June 2010 at
the World Wide
Developers Con-
ference, Apple
announced ver-
sion 4 of Xcode
during the Devel-
oper Tools State
of the Union ad-
dress.

最佳答案

使用带有 hyphenationFactor 为 1 的 NSParagraphStyle 的 NSAttributedString。

关于ios - IOS 中的正字连字词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16502556/

相关文章:

ios - 如何使 initWithNibName 表现得像 instantiateViewControllerWithIdentifier

当 HTTP 请求命中并且应用程序突然进入后台时,iOS 12 URLSession 中断

ios - 使用 XCUITest 测试 UIView 是否被隐藏

ios - 如何从分组的 UITableView 的单元格中删除边框?

objective-c - mfmailcomposer 剪切 html 电子邮件的结尾

ios - Swift 如何从源自 lib 的字符串创建类实例

ios - 如何禁用 GUITabPageViewController 中的滚动条指示器

objective-c - 更新应用程序时如何处理偏好设置?

ios - 为什么 UITableViewCell 的高度小于其文本的高度?

xcode - 为什么NSString使我的Release版本崩溃,但是在Xcode里面可以工作?