Skip to content

Repository files navigation

Highlighter

Awesome Swift Package Manager CocoaPods Platform Swift 6 License: MIT

Updates

See CHANGELOG for details

Introduction

🖍 Highlight whatever you want! Highlighter will magically find UI objects such as UILabel, UITextView, UITextField, UIButton in your UITableViewCell or other Class.

See YNSearch for advanced usage

demo

Requirements

Highlighter requires Swift 6.0 (swift-tools-version 6.0) and iOS 13.0 or later. It supports Swift Package Manager and CocoaPods.

Installation

Swift Package Manager

In Xcode, choose File ▸ Add Package Dependencies… and enter:

https://github.com/younatics/Highlighter.git

Or add it to your Package.swift:

dependencies: [
    .package(url: "https://github.com/younatics/Highlighter.git", from: "2.0.0")
]

CocoaPods

Highlighter is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Highlighter', '2.0.0'

Usage

You can highlight a UILabel, UITextView, UITextField, or UIButton using highlight(text:normal:highlight:). When you call highlight(text:normal:highlight:type:) on a container such as a custom UIView or UITableViewCell, Highlighter inspects the container's stored properties and highlights directly stored supported controls. It does not recursively search UIView.subviews.

To highlight all supported controls stored as properties, use:

view.highlight(text: "Foo", normal: normalAttributes, highlight: highlightedAttributes)

Or limit the stored properties to a single control type:

view.highlight(text: "Foo", normal: normalAttributes, highlight: highlightedAttributes, type: UIButton.self)

Examples

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: [.backgroundColor: UIColor.yellow])
  }
  return cell
}

References

Please tell me or make pull request if you use this library in your application :)

Author

younatics Twitter

License

Highlighter is available under the MIT license. See the LICENSE file for more info.

About

🖍 Highlight whatever you want!

Topics

Resources

Stars

922 stars

Watchers

12 watching

Forks

Releases

Packages

Used by

Contributors

Languages