Skip to content

Repository files navigation

ICInputAccessory

Customized text fields used in the iCook app.

Build StatusCarthage compatibleCocoaPods CompatiblePlatformSwift 5

KeyboardDismissTextField

  • A text field that has a button to dismiss keyboard on the input accessory view.

TokenField

  • A horizontal scrolling UI that groups input texts.
  • Easy to add, select and delete tokens.
  • Customizable icon and colors.
  • Supports storyboard.

ICTokenField

OptionPickerControl

  • An easy to use UIControl that displays a UIPickerView with given options.

Requirements

ICInputAccessoryiOSXcodeSwift
~> 1.0.08.0+7.2Swift 2.1.1
~> 1.1.08.0+7.3Swift 2.2
~> 1.2.08.0+8.0Swift 2.3
~> 1.3.08.0+8.0Swift 3.0
~> 1.4.08.0+8.3Swift 3.1
~> 1.5.08.0+9.3Swift 4.1
~> 2.0.08.0+10.0Swift 4.1
develop8.0+11.1Swift 5.0

Installation

Create a Cartfile with the following specification and run carthage update ICInputAccessory. Follow the instructions to add the framework to an iOS project.

github "polydice/ICInputAccessory"

ICInputAccessory supports subspecs. Create a Podfile with the following specification and run pod install.

platform:ios,'8.0'use_frameworks!pod'ICInputAccessory/TokenField'pod'ICInputAccessory/KeyboardDismissTextField'

Use Git Submodule

git submodule add -b master git@github.com:polydice/ICInputAccessory.git Dependencies/ICInputAccessory
  • Everything you need resides in the Source directory. Add those files to your project.
  • Alternatively, drag ICInputAccessory.xcodeproj to your app project as a subproject. Add ICInputAccessory-iOS to the Target Dependencies in the application target's Build Phases settings.

Usage

KeyboardDismissTextField

lettextField=KeyboardDismissTextField(frame: rect)

TokenField

lettokenField=TokenField(frame: rect)
tokenField.delegate =selfas?TokenFieldDelegate

The characters that complete a token:

/// Characters that complete a new token, defaults are whitespace and commas.
publicvardelimiters:[String]

Tokens:

/// Texts of each created token.
publicvartexts:[String]{get}
/// Creates a token with the current input text.
publicfunc completeCurrentInputText()
/// Removes the input text and all displayed tokens.
public func resetTokens()

UI customization:

/// The image on the left of text field.
publicvaricon:UIImage?{getset}
/// The placeholder with the default color and font.
publicvarplaceholder:String?{getset}
/// The placeholder with customized attributes.
publicvarattributedPlaceholder:NSAttributedString?{getset}
/// Customized attributes for tokens in the normal state, e.g. .font and .foregroundColor.
publicvarnormalTokenAttributes:[NSAttributedStringKey:NSObject]?{getset}
/// Customized attributes for tokens in the highlighted state.
publicvarhighlightedTokenAttributes:[NSAttributedStringKey:NSObject]?{getset}

Customizable properties in storyboard:

@IBInspectablevaricon:UIImage?@IBInspectablevarplaceholder:String?@IBInspectablevartextColor:UIColor?@IBInspectablevarcornerRadius:CGFloat

See Example/CustomizedTokenField.swift for more details.

TokenFieldDelegate

TokenField currently notifies its delegate the following events:

@objcoptionalfunc tokenFieldDidBeginEditing(_ tokenField:TokenField)@objcoptionalfunc tokenFieldDidEndEditing(_ tokenField:TokenField)@objcoptionalfunc tokenFieldWillReturn(_ tokenField:TokenField)@objcoptionalfunc tokenField(_ tokenField:TokenField, didChangeInputText text:String)@objcoptionalfunc tokenField(_ tokenField:TokenField, shouldCompleteText text:String)-> Bool
@objc optional func tokenField(_ tokenField:TokenField, didCompleteText text:String)@objc optional func tokenField(_ tokenField:TokenField, didDeleteText text:String, atIndex index:Int)

The displayed delimiter string can be customized by:

@objcoptionalfunc tokenField(_ tokenField:TokenField, subsequentDelimiterForCompletedText text:String)->String

OptionPickerControl

An example type that conforms to OptionDescriptive:

extensionString:OptionDescriptive{vartitle:String{returnself}staticvartitleForOptionalValue:String{return"(optional)"}}

To initialize OptionPickerControl with CGRect.zero and add it to the view hierarchy:

letoptionPicker=OptionPickerControl<String>()
optionPicker.options =[.optional,Option("Option 1"),Option("Option 2")]
optionPicker.addTarget(self, action: #selector(didChangeOption(_:)), for:.valueChanged)
view.addSubview(optionPicker)

To show the UIPickerView:

optionPicker.becomeFirstResponder()

Documentation

Development

  • Set up dependencies by running the following command in the project root:

    make bootstrap
    
  • Open ICInputAccessory.xcworkspace and run the demo app with the Example scheme.

  • See more tasks for building and testing:

    rake -T
    

Contributing

Thank you for being interested in contributing to this project. We'd love to hear your ideas!

Please fork this repository, create a branch named like feature/some-new-feature and send us a pull request to make this project better.

Contact

TwitterJoin the chat at https://gitter.im/polydice/ICInputAccessory

License

Copyright (c) 2016 Polydice, Inc.

ICInputAccessory is released under the MIT license. See LICENSE for details.

About

A customized token text field used in the iCook app.

Resources

Stars

51 stars

Watchers

17 watching

Forks

Releases

Packages

Used by

Contributors

Languages