【发布时间】:2012-02-09 09:46:03
【问题描述】:
我有一个 UITextView 用于输入照片的 cmets。当用户在 UITextView 中输入他们的文本时,输入的最后一个文本应该是深灰色,其他文本应该是正常颜色。用户输入 Space 后,最后输入的单词/文本应更改为黑色(正常)颜色。
UITextView text eg: iPhone is an apple product. Product should be in Dark gray color others in black color. Once user enter space the all entire words in black color.
如何检测最后输入的单词以及如何更改特定的最后输入单词的文本颜色?
已编辑:
我正在尝试这个源代码。
-(void) textViewDidChange:(UITextView *)textView
{
NSArray *lastTextArray = [textView.text componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
lastStringInTextView = [lastTextArray objectAtIndex:lastTextArray.count - 1];
NSLog(@"LastText : %@", lastStringInTopTextView);
textView.textColor = [UIColor orangeColor];
}
【问题讨论】:
-
有人知道吗?请帮助我的问题。谢谢。
-
还有一个问题:这个 cmets 会显示在 UIWebView 上还是只显示在 UIPhoto 等上?
-
@ilhançetin 谢谢。只是我将 UITextView 放在 UIViewController 中。这就是我的朋友。
标签: iphone ios text uitextview textcolor