高亮工具
更新
详细信息请参见更改日志
简介
Highlighter
将会神奇地在您的UITableViewCell
或其他Class
中找到UI对象,如UILabel
、UITextView
、UITextfield
和UIButton
。
YNSearch
关于高级用法,请查看要求
Highlighter
使用Swift 4.2编写。兼容iOS 9.0以上。
安装
Cocoapods
高亮工具可以通过 CocoaPods 获取。安装它,只需在您的 Podfile 中添加以下行
pod 'Highlighter'
Carthage
github "younatics/Highlighter"
使用方法
您可以使用 view.highlight(text:normal:highlight:type:)
搜索任何 UIView
。它将在子视图中搜索提供的 text
并使用提供的属性高亮显示它们。
要搜索所有支持的子视图,使用
view.highlight(text: "Foo", normal: normalAttributes, highlight: highlightedAttributes)
或者您可以使用
view.highlight(text: "Foo", normal: normalAttributes, highlight: highlightedAttributes, type: UIButton.self)
示例
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = self.ynSearchListViewDelegate?.ynSearchListView(tableView, cellForRowAt: indexPath) as? SearchViewCell else { return UITableViewCell() }
if let changedText = ynSearchTextFieldText {
cell.highlight(text: changedText, normal: nil, highlight: [NSBackgroundColorAttributeName: UIColor.yellow])
}
return cell
}
}
参考
请告诉我或者在你使用此库的应用程序中创建拉取请求 :)
MotionBook
YNSearch
作者
许可证
Highlighter 库受 MIT 许可证的许可。更多信息请参阅 LICENSE 文件。