高亮工具 1.4.0

高亮工具 1.4.0

[younatics] 维护。



  • 作者
  • 尹俊伊

高亮工具

Awesome Version Carthage Compatible License: MIT Build Status Platform Swift 4.2

更新

详细信息请参见更改日志

简介

🖍突出显示您想要的内容!Highlighter将会神奇地在您的UITableViewCell或其他Class中找到UI对象,如UILabelUITextViewUITextfieldUIButton

关于高级用法,请查看YNSearch

demo

要求

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

作者

younatics Twitter

许可证

Highlighter 库受 MIT 许可证的许可。更多信息请参阅 LICENSE 文件。