UITFCompletion 0.1.1

UITFCompletion 0.1.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release May 2017
SwiftSwift Version 3.1
SPMSupports SPM

Maintained by Matija Kruljac.



  • By
  • Matija Kruljac

UITFCompletion makes it easy to complete words or make tags of participants of group conversation for instance in UITextField like Facebook Messenger.

Example

To run the example project, clone the repo, and run pod install from the Example directory first. This gif shows example application in which collection and tag character can be edited.

Requirements

  • iOS 8.0+
  • Xcode 8
  • Swift 3.0

Installation

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

platform :ios, '8.0'
use_frameworks!

target 'MyApp' do
    pod "UITFCompletion"
end

Usage

Using UITFCompletion is very easy. Just call init method and pass all required parameters. Collection must be an array of Strings.TagCharactercan be set when collection is set with setup(collection: collection, withTagCharacter: String) method.

// initial setup for example
private var data = ["shark", "lion", "giraffe", "elephant", "orangutan", "dog", "cat"]
private var tagCharacter = "@" // or "##"

guard let parentView = userInputTextField.superview else { return }

// required parameters for initialization are UITextField for input and its parent view
// in init collection can be passed or not - if passed tagCharacter is "@" as default
uitfCompletionHandler = UITFCompletionHandler.init(with: userInputTextField, withParentView: parentView)

// setup collection and tagCharacter
// if setup(tagCharacter: String) is not called, tagCharacter will be "@" as default
uitfCompletionHandler.setup(collection: data)
uitfCompletionHandler.setup(tagCharacter: tagCharacter)

// colors for completion holder text and chosen tag can be changed - default color is .blue
uitfCompletionHandler.changeCompletionText(color: UIColor(red: 0, green: 0.6275, blue: 0.2275, alpha: 1.0))
uitfCompletionHandler.changeChosenTag(color: UIColor(red: 0.8863, green: 0, blue: 0.0588, alpha: 1.0))

Author

Matija Kruljac, [email protected]

License

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