Skip to content

jhaliya/Mentions

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 94.8%
  • Ruby 5.2%