jhaliya / Mentions

An easy way to add mentions and hashtags

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mentions

Version License Platform Support Language

An easy way to add mentions in UITextView.

Demo

Demo

Requirements

  • Swift 3.0
  • Xcode 8
  • iOS 8.0+

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

CocoaPods (recommended)

use_frameworks!

pod 'Mentions'

Usage

var mentionTextView = MentionTextView()
view.addSubview(mentionTextView)

// initial text with mention.
mentionTextView.mentionText = "who is your favorite actor or actress? I like [Will Smith] and [Robert Pattinson] the best."

// add to mention.
mentionTextView.insert(to: "Leonardo DiCaprio", with: mentionTextView.selectedRange)

If you want to show the text that contains the mention, set it as follows.

var textLabel = MentionLabel()
view.addSubview(textLabel)

textLabel.text = mentionTextView.mentionText

// or Add the text of the mention inside special characters "[]".
textLabel.text = "[Brad Pitt]"


// show the mention text.
textLabel.tapHandler = { (mention) in
  let alert = UIAlertView(title: "", message: mention, delegate: nil, cancelButtonTitle: nil, otherButtonTitles: "OK")
  alert.show()
}

Author

magicmon, http://magicmon.github.io

License

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

About

An easy way to add mentions and hashtags

License:MIT License


Languages

Language:Swift 94.8%Language:Ruby 5.2%