【发布时间】:2010-12-09 09:04:08
【问题描述】:
我现在正在实现一本电子书,当文本的音频播放时,我必须在其中突出显示每个单词。突出显示的颜色将在 2 秒后消失。我们如何为文本添加背景颜色。我没有使用 UILabel,因为有很多句子的冗长文本。 我们应该怎么做?任何人请帮忙!谢谢!
【问题讨论】:
标签: iphone objective-c xcode core-animation core-graphics
我现在正在实现一本电子书,当文本的音频播放时,我必须在其中突出显示每个单词。突出显示的颜色将在 2 秒后消失。我们如何为文本添加背景颜色。我没有使用 UILabel,因为有很多句子的冗长文本。 我们应该怎么做?任何人请帮忙!谢谢!
【问题讨论】:
标签: iphone objective-c xcode core-animation core-graphics
I think u should use UIWebView rather than UITextView, and dynamically u can
highlight the text by adding html tags and style tag around a particular string. But
for that u need to track which string or text audio is playing. Both of these operations
should be performed simultaneously,i.e., Audio Playing and attaching tags aroynd the tags.
Now if u want to fade off the color of the text after two seconds , simply call function
after delay of two seconds, in which u can change the text color back to earlier on.
To call function after delay u should go for
[self performSelector:@selector(changeTooriginalColor) withObject:nil afterDelay:2];
第二个问题的答案:
UIWebView *wizardSpeechWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0,100,320,265)];
wizardSpeechWebView.backgroundColor = [UIColor clearColor];
wizardSpeechWebView.opaque = NO;
wizardSpeechWebView.delegate = self;
[self.view addSubview:wizardSpeechWebView];
【讨论】: