๐Ÿ– Highlight whatever you want!

Overview

Highlighter

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

Updates

See CHANGELOG for details

Intoduction

๐Ÿ– 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 is written in Swift 5.0. Compatible with iOS 9.0+

Installation

Cocoapods

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

pod 'Highlighter'

Carthage

github "younatics/Highlighter"

Usage

You can search any UIView using view.highlight(text:normal:highlight:type:) It will search subviews for the provided text and highlight them using the attributes provided.

To search all supported subview use:

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

or you can limit the search to a single type using:

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

References

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

MotionBook

YNSearch

Author

younatics Twitter

License

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

Comments
  • Pop implementation

    Pop implementation

    As discussed in https://github.com/younatics/Highlighter/issues/2 here is the POP implementation.

    This should be a major version change since it contains breaking changes to the syntax.

    Please give it a quick test before merging.

    ๐Ÿค˜

    opened by IanKeen 2
  • POP Implementation

    POP Implementation

    Hey, Interesting lib

    I had a quick play at a protocol oriented version if you are interested

    https://gist.github.com/IanKeen/537d70bf02fad763c096e6fbb5c1dc69

    The biggest pro to this approach is you are able to break out the highlightable elements and use protocol extensions to provide a default highlighting implementation.

    The boilerplate for the elements that conform to Highlightable would have been reduced greatly if UITextView didn't use IUOs for its text/attributedText properties :(

    The only API change this introduces is the removal of the HighlighterType enum. Instead you just pass in the type of the item you are targeting i.e. UIButton.self for buttons or nil for everything.

    Let me know if you'd be interested in a PR

    opened by IanKeen 1
  • Out of bounds, case crash.

    Out of bounds, case crash.

    Problem

    App crashed when the text of UILabel is come from network data parse.May be caused by string encoding. I simulated the scene with SwiftPlayground.

    let key = "ๅคฉ"
    let text = String(data: "ๆ˜Žๅคฉๅผ€ๅง‹".data(using: .unicode)!, encoding: .unicode)!
    let ranges = text.lowercased().ranges(of: key)
    print("matchedRanges: \(ranges)")
    // matchedRanges: [Range(Swift.String.Index(_rawBits: 196608)..<Swift.String.Index(_rawBits: 393216))]
    
    print("originText.endIndex: \(text.endIndex)")
    // originText.endIndex: Index(_rawBits: 262144)
    
    print("lowercased.endIndex: \(text.lowercased().endIndex)")
    // lowercased.endIndex: Index(_rawBits: 786432)
    

    The upperBound of matched range is greater than the originText.endIndex.

    Solution

    Remove the lowercased option before match range and use CompareOptions.caseInsensitive as the default value of ranges method.

    I am happy to submit PR if you allow it.

    opened by orangeince 0
  • NSAttributedString extension highlight function bug.

    NSAttributedString extension highlight function bug.

    There is a bug in the highlight function. It occurs when more than one range is in the input. Line 22: highlightString.append(self.containAttribute(originText: originText, bound: ranges[i], attributes: highlightAttributes))

    It takes wrong occurrence. Next, instead of needed one. For example if originText = "String string String" and searchText = "string", then result will be (omitting attributes) "string String String". In fact you can clearly see this bug in the introduction gif (https://raw.githubusercontent.com/younatics/Highlighter/master/Images/Highlighter.gif)

    opened by mgorvat 0
  • add unHighlight even for attribute text

    add unHighlight even for attribute text

    When the project use Highlighter to highlight cell, if the cell contain label using attribute string. This highlight method will make the label cache highlighted attribute string

    opened by ducnguyenenterprise 0
Releases(1.4.0)
Owner
Kyle Yi
Kyle Yi
Texstyle allows you to format iOS attributed strings easily.

Texstyle allows you to format attributed strings easily. Features Applying attributes with strong typing and autocompletion Cache for attributes Subst

Rosberry 79 Sep 9, 2022
The application is develop in Objective IOS. kids can draw whatever they want and also kids can save the drawing as well as undo erase the drawing.

IOSObjC_KidsBoard The application is develop in Objective IOS. kids can draw whatever they want and also kids can save the drawing as well as undo era

Haresh 0 Oct 28, 2021
Analyser BPM in Swift for your music/sounds/records, whatever..

BPM-Analyser Analyser BPM in Swift for your music/sounds/records, whatever.. Powered with Superpowered Preview: How To: Copy theese files to your proj

Gleb Karpushkin 71 Dec 24, 2022
Egg Timer app helps you to cook your egg in the way you want

Egg Timer Egg Timer app helps you to cook your egg in the way you want. You need to decide on how do you want to eat your egg than just click the egg

Emrullah Cirit 2 Nov 29, 2022
add text(multiple line support) to imageView, edit, rotate or resize them as you want, then render the text on image

StickerTextView is an subclass of UIImageView. You can add multiple text to it, edit, rotate, resize the text as you want with one finger, then render the text on Image.

Textcat 478 Dec 17, 2022
Lickable-Button We made the buttons on the screen look so good you'll want to lick them

Lickable-Button We made the buttons on the screen look so good you'll want to lick them. - Steve Jobs A little SwiftUI button project at WWDC 2021 Lic

Nate Thompson 14 Dec 29, 2021
LibAuthentication will simplify your code when if you want to use FaceID/TouchID in your tweaks.

LibAuthentication will simplify your code when if you want to use FaceID/TouchID in your tweaks.

Maximehip 6 Oct 3, 2022
Use this template as a starting point for any Swift 5 module that you want other people to include in their projects

Swift 5 Module Template Use this template as a starting point for any Swift 5 mo

James Knipe 0 Dec 28, 2021
FreshPlan - meet-up app that plans when you guys want to meet

FreshPlan meet-up app that plans when you guys want to meet. Requirements Cocoap

Allan Lin 1 Jan 4, 2022
Quickly search the built-in iOS dictionary to see definitions of words. Collect words you want to remember.

Kotoba Quickly search the built-in iOS dictionary to see definitions of words. Collect words you want to remember. Installation (iPhone or iPad) Note:

Will Hains 452 Dec 26, 2022
MarkdownView is a WKWebView based UI element, and internally use bootstrap, highlight.js, markdown-it.

MarkdownView is a WKWebView based UI element, and internally use bootstrap, highlight.js, markdown-it.

Keita Oouchi 1.8k Dec 21, 2022
UISlider clone with multiple thumbs and values, range highlight, optional snap intervals, optional value labels, either vertical or horizontal.

MultiSlider UISlider clone with multiple thumbs and values, range highlight, optional snap intervals, optional value labels, either vertical or horizo

Yonat Sharon 326 Dec 29, 2022
CodeEditor - A SwiftUI TextEditor with syntax highlighting using Highlight.js

CodeEditor A SwiftUI TextEditor View with syntax highlighting using Highlight.js. It builds on top of Highlightr which does the wrapping of Highlight.

ZeeZide 269 Dec 30, 2022
iOS Chart. Support animation, click, scroll, area highlight.

XJYChart XJYChart - A High-performance, Elegant, Easy-to-integrate Charting Framework. The Best iOS Objc Charts. chart more beautiful support chart sc

junyixie 868 Nov 16, 2022
Weather Forecast Assigment is an iOS application built to highlight MVP and Clean Architecture concepts

Weather Forecast Assigment - iOS - MVP + Clean Architecture Description Weather Forecast Assigment is an iOS application built to highlight MVP (Model

Khรดi Viแป‡t 2 Oct 30, 2021
UISlider clone with multiple thumbs and values, range highlight, optional snap intervals, optional value labels, either vertical or horizontal.

MultiSlider UISlider clone with multiple thumbs and values, range highlight, optional snap intervals, optional value labels, either vertical or horizo

Yonat Sharon 326 Dec 29, 2022
WVWalkthroughView is an objective C based utility to highlight certain parts for iOS apps.

WVWalkthroughView A simple utility written in Objective C to help developers walk a user through their app. It allows a message to be displayed, a par

Praagya Joshi 29 Mar 25, 2021
swift-highlight a pure-Swift data structure library designed for server applications that need to store a lot of styled text

swift-highlight is a pure-Swift data structure library designed for server applications that need to store a lot of styled text. The Highlight module is memory-efficient and uses slab allocations and small-string optimizations to pack large amounts of styled text into a small amount of memory, while still supporting efficient traversal through the Sequence protocol.

kelvin 4 Aug 14, 2022
A Xcode plugin to add highlight to the instances of selected symbol.

Auto Highlight Symbol About Xcode 8 Xcode 8 does't support plugins anymore, but there is a workaround, use at your own risk. Xcode can highlight insta

Nelson 83 Jan 3, 2023
This is an app for coffee drinkers who want to find out what they're ideal bedtime is.

BetterRest This is an app for coffee drinkers who want to find out what they're ideal bedtime is. This was a part of my SwiftUI course. In this app my

Alex Diaz 0 Jan 19, 2022