Giter Site home page Giter Site logo

josejulio / autocompletefield Goto Github PK

View Code? Open in Web Editor NEW

This project forked from filipstefansson/autocompletefield

0.0 3.0 0.0 17 KB

Add word completion to your UITextFields.

Home Page: http://iosdev.io/autocompletefield/

License: MIT License

Ruby 12.54% Swift 87.46%

autocompletefield's Introduction

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.

autocompletefield's People

Contributors

filipstefansson avatar

Watchers

 avatar  avatar  avatar

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.