@@ -8,11 +8,11 @@ Customized text fields used in the [iCook app](https://itunes.apple.com/app/id55
88![ Platform] ( https://img.shields.io/cocoapods/p/ICInputAccessory.svg )
99![ Swift 4.1] ( https://img.shields.io/badge/Swift-4.1-orange.svg )
1010
11- ### ICKeyboardDismissTextField
11+ ### KeyboardDismissTextField
1212
1313* A text field that has a button to dismiss keyboard on the input accessory view.
1414
15- ### ICTokenField
15+ ### TokenField
1616
1717* A horizontal scrolling UI that groups input texts.
1818* Easy to add, select and delete tokens.
@@ -21,6 +21,10 @@ Customized text fields used in the [iCook app](https://itunes.apple.com/app/id55
2121
2222![ ICTokenField] ( https://polydice.github.io/ICInputAccessory/screenshots/ICTokenField.gif )
2323
24+ ### OptionPickerControl
25+
26+ * An easy to use ` UIControl ` that displays a ` UIPickerView ` with given options.
27+
2428## Requirements
2529
2630ICInputAccessory | iOS | Xcode | Swift
@@ -31,6 +35,7 @@ ICInputAccessory | iOS | Xcode | Swift
3135` ~> 1.3.0 ` | 8.0+ | 8.0 | ![ Swift 3.0] ( https://img.shields.io/badge/Swift-3.0-orange.svg )
3236` ~> 1.4.0 ` | 8.0+ | 8.3 | ![ Swift 3.1] ( https://img.shields.io/badge/Swift-3.1-orange.svg )
3337` ~> 1.5.0 ` | 8.0+ | 9.3 | ![ Swift 4.1] ( https://img.shields.io/badge/Swift-4.1-orange.svg )
38+ ` ~> 2.0.0 ` | 8.0+ | 10.0 | ![ Swift 4.1] ( https://img.shields.io/badge/Swift-4.1-orange.svg )
3439
3540## Installation
3641
@@ -65,27 +70,27 @@ git submodule add -b master git@github.com:polydice/ICInputAccessory.git Depende
6570
6671## Usage
6772
68- ### ICKeyboardDismissTextField
73+ ### KeyboardDismissTextField
6974
7075``` swift
71- let textField = ICKeyboardDismissTextField (frame : rect)
76+ let textField = KeyboardDismissTextField (frame : rect)
7277```
7378
74- ### ICTokenField
79+ ### TokenField
7580
7681``` swift
77- let tokenField = ICTokenField (frame : rect)
78- tokenField.delegate = self as? ICTokenFieldDelegate
82+ let tokenField = TokenField (frame : rect)
83+ tokenField.delegate = self as? TokenFieldDelegate
7984```
8085
81- * The characters that complete a token:
86+ The characters that complete a token:
8287
8388``` swift
8489/// Characters that complete a new token, defaults are whitespace and commas.
8590public var delimiters: [String ]
8691```
8792
88- * Tokens:
93+ Tokens:
8994
9095``` swift
9196/// Texts of each created token.
@@ -98,7 +103,7 @@ public func completeCurrentInputText()
98103public func resetTokens ()
99104```
100105
101- * UI customization:
106+ UI customization:
102107
103108``` swift
104109/// The image on the left of text field.
@@ -110,14 +115,14 @@ public var placeholder: String? { get set }
110115/// The placeholder with customized attributes.
111116public var attributedPlaceholder: NSAttributedString? { get set }
112117
113- /// Customized attributes for tokens in the normal state, e.g. NSFontAttributeName and NSForegroundColorAttributeName .
114- public var normalTokenAttributes: [String : NSObject]? { get set }
118+ /// Customized attributes for tokens in the normal state, e.g. .font and .foregroundColor .
119+ public var normalTokenAttributes: [NSAttributedStringKey : NSObject]? { get set }
115120
116121/// Customized attributes for tokens in the highlighted state.
117- public var highlightedTokenAttributes: [String : NSObject]? { get set }
122+ public var highlightedTokenAttributes: [NSAttributedStringKey : NSObject]? { get set }
118123```
119124
120- * Customizable properties in storyboard:
125+ Customizable properties in storyboard:
121126
122127``` swift
123128@IBInspectable var icon: UIImage?
@@ -128,24 +133,57 @@ public var highlightedTokenAttributes: [String : NSObject]? { get set }
128133
129134See ` Example/CustomizedTokenField.swift ` for more details.
130135
131- #### ICTokenFieldDelegate
136+ #### TokenFieldDelegate
132137
133- ` ICTokenField ` currently notifies its delegate the following events:
138+ ` TokenField ` currently notifies its delegate the following events:
134139
135140``` swift
136- @objc optional func tokenFieldDidBeginEditing (_ tokenField : ICTokenField )
137- @objc optional func tokenFieldDidEndEditing (_ tokenField : ICTokenField )
138- @objc optional func tokenFieldWillReturn (_ tokenField : ICTokenField )
139- @objc optional func tokenField (_ tokenField : ICTokenField , didChangeInputText text : String )
140- @objc optional func tokenField (_ tokenField : ICTokenField , shouldCompleteText text : String ) -> Bool
141- @objc optional func tokenField (_ tokenField : ICTokenField , didCompleteText text : String )
142- @objc optional func tokenField (_ tokenField : ICTokenField , didDeleteText text : String , atIndex index : Int )
141+ @objc optional func tokenFieldDidBeginEditing (_ tokenField : TokenField )
142+ @objc optional func tokenFieldDidEndEditing (_ tokenField : TokenField )
143+ @objc optional func tokenFieldWillReturn (_ tokenField : TokenField )
144+ @objc optional func tokenField (_ tokenField : TokenField , didChangeInputText text : String )
145+ @objc optional func tokenField (_ tokenField : TokenField , shouldCompleteText text : String ) -> Bool
146+ @objc optional func tokenField (_ tokenField : TokenField , didCompleteText text : String )
147+ @objc optional func tokenField (_ tokenField : TokenField , didDeleteText text : String , atIndex index : Int )
143148```
144149
145150The displayed delimiter string can be customized by:
146151
147152``` swift
148- @objc optional func tokenField (_ tokenField : ICTokenField, subsequentDelimiterForCompletedText text : String ) -> String
153+ @objc optional func tokenField (_ tokenField : TokenField, subsequentDelimiterForCompletedText text : String ) -> String
154+ ```
155+
156+ ### OptionPickerControl
157+
158+ An example type that conforms to ` OptionDescriptive ` :
159+
160+ ``` swift
161+ extension String : OptionDescriptive {
162+
163+ var title: String {
164+ return self
165+ }
166+
167+ static var titleForOptionalValue: String {
168+ return " (optional)"
169+ }
170+
171+ }
172+ ```
173+
174+ To initialize ` OptionPickerControl ` with ` CGRect.zero ` and add it to the view hierarchy:
175+
176+ ``` swift
177+ let optionPicker = OptionPickerControl< String > ()
178+ optionPicker.options = [.optional , Option (" Option 1" ), Option (" Option 2" )]
179+ optionPicker.addTarget (self , action : #selector (didChangeOption (_:)), for : .valueChanged )
180+ view.addSubview (optionPicker)
181+ ```
182+
183+ To show the ` UIPickerView ` :
184+
185+ ``` swift
186+ optionPicker.becomeFirstResponder ()
149187```
150188
151189### Documentation
0 commit comments