在 iPhone 上突出显示滚动文本
我在显示歌词时遇到了麻烦。我使用 uitextview 显示歌词代码剪切
IBOutlet UILabel *lrcshow;
IBOutlet UITextView *showlrc;
self.lrcshow.text = [lrcDictss objectForKey:
[NSString stringWithFormat:@"%d",(int)self.player.currentTime]];
if (self.lrcshow.text!=nil) {
NSRange selection = [self.showlrc.text rangeOfString:self.lrcshow.text];
if( selection.location != NSNotFound ){
showlrc.selectedRange = selection;
}
}
歌词逐行滚动显示,问题是现在播放(selectedRange)歌词不突出显示,我想要这一行突出显示我该如何编码?有什么建议吗?或者用 calayer 、cgcontext 石英核心代替吗?我该怎么办?
ps.对我来说英语很难我想实现平滑滚动效果歌词显示
歌词样式显示图片网址:
这是我的应用程序样式:
这是很好的风格:flickr.com/photos/53054715@N05/5359722887/
i'm in troubled show lyrics .i use uitextview show lyrics code snips
IBOutlet UILabel *lrcshow;
IBOutlet UITextView *showlrc;
self.lrcshow.text = [lrcDictss objectForKey:
[NSString stringWithFormat:@"%d",(int)self.player.currentTime]];
if (self.lrcshow.text!=nil) {
NSRange selection = [self.showlrc.text rangeOfString:self.lrcshow.text];
if( selection.location != NSNotFound ){
showlrc.selectedRange = selection;
}
}
lyrics line by line scrolling show,the problem is now playing(selectedRange) lyric is not highlight, i want this line highlight how can i code ? any suggestion?or use calayer 、cgcontext quartz core instead it? how can I do it ?
ps.for me english is difficult I want to achieve smooth scrolling effect lyrics show
lyrics style show pic url :
this is my app style: http://www.flickr.com/photos/53054715@N05/5360345226/
this is good style : flickr.com/photos/53054715@N05/5359722887/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我明白你的意思...你想突出显示文本,而 selectedRange 不起作用?
如果是这样,请阅读以下内容:
selectedRange 仅在键盘显示时才起作用。在你的歌词应用程序中你不想要这样,对吗?
所以你至少需要一个 CALayer 来让它看起来像是被选中了。
您还需要文本的坐标,这不是一个简单的任务。
如果您的文本是静态的(字体、大小、框架宽度永远不会改变),那么您可以在字典中拥有文本的坐标,这样您就可以相应地调整 CALayer 的大小
希望它有帮助。
祝你好运
I think I understand what you mean... you want to highlight a text and selectedRange is not working right?
If so then read this:
selectedRange only works when the keyboard is showing. In your lyrics app you don't want that right?
So you will need at least a CALayer to make it look like is selected.
Also you need the coordinates of the text and that is no a simple task.
If your text is static (the font, size, frame width never changes) then you could have coordinates of the text in your dictionary, so you can resize your CALayer accordingly
Hope it helps.
GoodLuck