Code Monkey home page Code Monkey logo

mentions's Introduction

Mentions

Swift 5.7 Version Platform License

An easy way to add mentions in UITextView.

Demo

Demo

Requirements

  • Swift 5.7
  • Xcode 14.1
  • iOS 13.0+

Example

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

Installation

Swift Package Manager

The Swift Package Manager automates the distribution of Swift code. To use Mentions with SPM, add a dependency to https://github.com/magicmon/Mentions.git

CocoaPods

use_frameworks!

pod 'Mentions'

Usage

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

// initial text with mention.
mentionTextView.setMentionText("www.google.com or [magicmon]", 
                               pattern: .mention,
                               prefixMention: "@")
mentionTextView.deleteType = .cancel // or .delete

// add to mention.
mentionTextView.insert(to: "anonymous", 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.setMentionText(mentionTextView.mentionText,
                         pattern: .mention,
                         prefixMention: "@")

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

// show the mention text.
textLabel.tapHandler = { (mention) in
  let alert = UIAlertController(title: "", message: mention, preferredStyle: .alert)
  alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
  self.present(alert, animated: true, completion: nil)
}

Author

magicmon, https://magicmon.tistory.com

License

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

mentions's People

Contributors

magicmon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mentions's Issues

Delete mention

Can you completely delete the mention when you press it back?

Text trimming in mention label

when we assign UIlabel to mention label and using setMentionText(), then text not showing properly
trimming text image
Screenshot 2023-11-15 at 1 10 23 PM

original text image
Screenshot 2023-11-15 at 1 10 35 PM

but when i'm using normal UILabel then it showing properly.
also when i'm updating the func drawText in MentionLabel class to super.drawText(in: rect)
showing properly but not showing mentions

can you please check

Mentions are not updating when text cut operation is performed.

Hello there!
Whenever we select any text from MentionTextView and perform a cut operation then the previously selected mention disappears or it was showing in regular black color. also when we press the back button then it works fine.

Please check the video for more information.

Simulator.Screen.Recording.-.iPhone.15.-.2024-03-27.at.15.52.07.mp4

How can we fix this issue? please suggest.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.