ios - UILabel 的 TextContainer 上的排除路径

标签 ios iphone objective-c uitableview textkit

是否可以在 UILabel 上设置排除路径?苹果文档指出 UILabel 现在是基于 TextKit 构建的,但 UILabel 似乎没有公开 textContainer 属性。

我希望实现一个 tableview 单元格,其中包含多个标签和一个标签不应重叠的 roux 角标(Badge)(如下所示)。

enter image description here

如果无法使用 UILabel,我如何使 TextView 像 UILabel 一样(无滚动、选择等)并调整其大小以适合其内容?

最佳答案

UILabel 没有暴露 TextKit 堆栈是正确的,所以你不能设置排除路径。

但是,您并不是真的需要 UILabel;使用 TextKit 直接绘制到矩形图形上下文中很容易,现在您可以设置排除路径(因为您正在使用 TextKit 绘制)。要使用 TextKit 进行绘制,只需构建文本工具包“堆栈”,以您喜欢的任何方式进行自定义,然后在绘制时调用布局管理器的 drawBackgroundForGlyphRange:... drawGlyphsForGlyphRange:....

关于ios - UILabel 的 TextContainer 上的排除路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22580859/

相关文章:

ios - Swift 注释 "Tag"

ios - 我们可以通过我的应用程序访问任何 iphone 应用程序中播放的任何声音并应用均衡器吗

c++ - iPhone编译移植代码问题: calling a static templated function that's inside a templated class == fail

ios - NSDictionary allKeys,然后使用选择器与 keysSortedByValueUsingSelector 进行排序

iphone - 在 iPhone 的 LinkedIn 集成中共享图像

ios - 由于弃用而替换 self->isa

iphone - UILongPressGestureRecognizer - 只识别最后一次按下

ios - iPhone 6/6 Plus : UITableView separator flickering and different thickness

ios - Swift - 从 URL 下载图像后如何调整 UICollectionViewCell 的大小?

iphone - 应用内购买和优惠券