开发者

Highlighting the background color of a text with fading animation after 1 sec

开发者 https://www.devze.com 2023-01-29 09:48 出处:网络
I am now implementing an ebook in which I have to highlight each word when the audio of the text plays. The highlighted color will fade off after 2 sec. How can we add a background color for the text.

I am now implementing an ebook in which I have to highlight each word when the audio of the text plays. The highlighted color will fade off after 2 sec. How can we add a background color for the text. I am not using UILabel si开发者_JAVA百科nce there are lengthy text with many sentences. How can we do this? Anyone please help! Thanks!


            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]; 

Your Second Question's anawer:

UIWebView *wizardSpeechWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0,100,320,265)];
wizardSpeechWebView.backgroundColor = [UIColor clearColor];
wizardSpeechWebView.opaque = NO; 
wizardSpeechWebView.delegate = self;
[self.view addSubview:wizardSpeechWebView];
0

精彩评论

暂无评论...
验证码 换一张
取 消