UITFCompletion 0.1.1

UITFCompletion 0.1.1

测试已测试
Lang语言 SwiftSwift
许可 MIT
发布上次发布2017年5月
SwiftSwift 版本3.1
SPM支持 SPM

Matija Kruljac 维护。



  • Matija Kruljac

UITFCompletion 可以轻松完成单词或为团体对话中的参与者设置标签,例如在 UITextField 中,就像 Facebook Messenger 一样。

示例

要运行示例项目,首先克隆仓库,然后从 Example 目录中运行 pod install。此 gif 展示了示例应用程序,其中可以编辑集合和标签字符。

要求

  • iOS 8.0+
  • Xcode 8
  • Swift 3.0

安装

UITFCompletion 可以通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile

platform :ios, '8.0'
use_frameworks!

target 'MyApp' do
    pod "UITFCompletion"
end

用法

使用 UITFCompletion 非常简单。只需调用 init 方法并传递所有必需的参数。集合必须是一个 String 数组。TagCharacter 可以在设置 collection 时通过 setup(collection: collection, withTagCharacter: String) 方法设置。

// 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))

作者

Matija Kruljac,[email protected]

许可

UITFCompletion 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。