AutocompleteField

Add word completion to your UITextFields.

Github星跟蹤圖

AutocompleteField

AutocompleteField let's you add word completion to your UITextFields.

Autocomplete, or word completion, is a feature in which an application predicts the rest of a word a user is typing.

How it works

AutocompleteField

Installation

Manual installation

Import AutocompleteField.swift into your project.

CocoaPods

platform :ios, '8.0'
pod "AutocompleteField", "~> 1.1" 

Usage

The easiest way is to add a UITextField in your Storyboard, and then giving it the AutocompleteField subclass. You can use the property editor to change both the padding and the completion color of the textfield.

If you want to add a field using code, there's a custom init method you can use:

import AutocompleteField

let textField = AutocompleteField(frame: CGRectMake(10, 10, 200, 40), suggestions: ["Abraham", "George", "Franklin"])
view.addSubview(textField)

Customization

AutocompleteField is a subclass of UITextField, so you can modify it in the same way you normally would, without any restrictions. The new properties you can set are:

Property, Type, Description
---------, ----, -----------
padding, CGFloat, Left/right padding.
completionColor, UIColor, The color of the suggestion. Defaults to the default placeholder color.
suggestion, String, The current suggestion shown. Can be used to force a suggestion.
suggestions, [String], Array of suggestions.
autocompleteType, AutocompleteType, The type of autocomplete that should be used. .Word will only hint the the next word in the suggestion and .Sentence will show all words.
pixelCorrection, CGFloat, Move the suggestion label up or down. Sometimes there's a small difference, and this can be used to fix it.

Demo

Check out the Example project.

Todo

  • Smarter suggestions. If both John Doe and John Smith are in the suggestion array, only Joe should be suggested.
  • Tests

License

AutocompleteField is provided under the MIT License. See LICENSE for details.

主要指標

概覽
名稱與所有者filipstefansson/AutocompleteField
主編程語言Swift
編程語言Swift (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2015-11-08 14:42:20
推送於2020-10-13 08:59:57
最后一次提交2020-10-13 10:59:52
發布數3
最新版本名稱2.0 (發布於 )
第一版名稱1.0 (發布於 )
用户参与
星數665
關注者數14
派生數40
提交數10
已啟用問題?
問題數6
打開的問題數3
拉請求數1
打開的拉請求數0
關閉的拉請求數5
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?