使用UISearchBar在UITableView中突出显示搜索到的文本 [英] Highlight the searched text in UITableView using UISearchBar

查看:39
本文介绍了使用UISearchBar在UITableView中突出显示搜索到的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用UISearchBar在UITableView中搜索文本.我只想知道如何突出显示搜索到的文本.突出显示可以使文本变为粗体或更改文本颜色.

Using UISearchBar searching text in UITableView. I just want to know how to highlight searched text. Highlighting could be make text bold or change text color.

例如如果我正在UITableView中使用UISearchBar搜索文本"Stack",其中包含带有字符串"Stackoverflow"的行,那么我的搜索结果应以这种方式显示为" Stack overflow".

E.g. If I'm searching text "Stack" using UISearchBar in UITableView which contains a row with string "Stackoverflow", now my search result should appear this way "Stackoverflow".

谢谢. 编码愉快..

推荐答案

通常,足以过滤符合您搜索条件的UITableView中的单元格.希望您了解如何安排.如果要在单元格中突出显示搜索词,则单元格需要支持此类突出显示,而不是可以突出显示调用[mycell highlightText:searchBar.text]之类的内容.就绪单元格不支持这种突出显示,您需要构建自定义单元格来做到这一点.

Usually it's enough to filter cells in UITableView conforming your search term. Hope you understand how that could be arranged. If you want highlight search term in a cell, your cell needs to support such highlight, than you could highlight calling something like [mycell highlightText:searchBar.text]. Ready cells don't support such highlight, you need to build your custom cell which will do that.

这篇关于使用UISearchBar在UITableView中突出显示搜索到的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆