我使用UILabel以多行和UILineBreakModeWordWrap模式显示我的文本,最大宽度为200.
例如,这里是文本:
I really really want to underline first word and second word, could you help me?
我想强调"第一个字"和"第二个字".
如果文本以单行模式显示,使用NSString的sizeWithFont方法,我可以轻松地计算"第一个单词"的位置,然后覆盖 - (void)drawTextInRect:(CGRect)rect来绘制该行.
但在多线模式下,我不知道如何获得这个位置.你有什么主意吗?