0

我正在寻找我的文本视图中的所有文本都是灰色的,然后第一句话是黑色的。如何将该范围设置为黑色。我已经有了第一句字符串/范围。谢谢你。

    [tv setTextColor:[UIColor grayColor]];

    id<UITextInputTokenizer> tokenizer = tv.tokenizer;
    UITextRange *range = [tokenizer rangeEnclosingPosition:tv.beginningOfDocument
                                           withGranularity:UITextGranularitySentence
                                               inDirection:UITextStorageDirectionForward];
    NSString *firstSentence = [tv textInRange:range];
    NSLog(@"%@",firstSentence);
4

1 回答 1

0

这里没有太多好消息。您需要一个 NSAttributed 字符串,但这不能用作标准文本视图的模型。我没有亲自检查过,但这里有一些可能有助于参考的网络代码......

于 2012-07-28T17:51:28.753 回答