@@ -8,11 +8,11 @@ Customized text fields used in the [iCook app](https://itunes.apple.com/app/id55
8
8
![ Platform] ( https://img.shields.io/cocoapods/p/ICInputAccessory.svg )
9
9
![ Swift 4.1] ( https://img.shields.io/badge/Swift-4.1-orange.svg )
10
10
11
- ### ICKeyboardDismissTextField
11
+ ### KeyboardDismissTextField
12
12
13
13
* A text field that has a button to dismiss keyboard on the input accessory view.
14
14
15
- ### ICTokenField
15
+ ### TokenField
16
16
17
17
* A horizontal scrolling UI that groups input texts.
18
18
* 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
21
21
22
22
![ ICTokenField] ( https://polydice.github.io/ICInputAccessory/screenshots/ICTokenField.gif )
23
23
24
+ ### OptionPickerControl
25
+
26
+ * An easy to use ` UIControl ` that displays a ` UIPickerView ` with given options.
27
+
24
28
## Requirements
25
29
26
30
ICInputAccessory | iOS | Xcode | Swift
@@ -31,6 +35,7 @@ ICInputAccessory | iOS | Xcode | Swift
31
35
` ~> 1.3.0 ` | 8.0+ | 8.0 | ![ Swift 3.0] ( https://img.shields.io/badge/Swift-3.0-orange.svg )
32
36
` ~> 1.4.0 ` | 8.0+ | 8.3 | ![ Swift 3.1] ( https://img.shields.io/badge/Swift-3.1-orange.svg )
33
37
` ~> 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 )
34
39
35
40
## Installation
36
41
@@ -65,27 +70,27 @@ git submodule add -b master
[email protected] :polydice/ICInputAccessory.git Depende
65
70
66
71
## Usage
67
72
68
- ### ICKeyboardDismissTextField
73
+ ### KeyboardDismissTextField
69
74
70
75
``` swift
71
- let textField = ICKeyboardDismissTextField (frame : rect)
76
+ let textField = KeyboardDismissTextField (frame : rect)
72
77
```
73
78
74
- ### ICTokenField
79
+ ### TokenField
75
80
76
81
``` 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
79
84
```
80
85
81
- * The characters that complete a token:
86
+ The characters that complete a token:
82
87
83
88
``` swift
84
89
/// Characters that complete a new token, defaults are whitespace and commas.
85
90
public var delimiters: [String ]
86
91
```
87
92
88
- * Tokens:
93
+ Tokens:
89
94
90
95
``` swift
91
96
/// Texts of each created token.
@@ -98,7 +103,7 @@ public func completeCurrentInputText()
98
103
public func resetTokens ()
99
104
```
100
105
101
- * UI customization:
106
+ UI customization:
102
107
103
108
``` swift
104
109
/// The image on the left of text field.
@@ -110,14 +115,14 @@ public var placeholder: String? { get set }
110
115
/// The placeholder with customized attributes.
111
116
public var attributedPlaceholder: NSAttributedString? { get set }
112
117
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 }
115
120
116
121
/// Customized attributes for tokens in the highlighted state.
117
- public var highlightedTokenAttributes: [String : NSObject]? { get set }
122
+ public var highlightedTokenAttributes: [NSAttributedStringKey : NSObject]? { get set }
118
123
```
119
124
120
- * Customizable properties in storyboard:
125
+ Customizable properties in storyboard:
121
126
122
127
``` swift
123
128
@IBInspectable var icon: UIImage?
@@ -128,24 +133,57 @@ public var highlightedTokenAttributes: [String : NSObject]? { get set }
128
133
129
134
See ` Example/CustomizedTokenField.swift ` for more details.
130
135
131
- #### ICTokenFieldDelegate
136
+ #### TokenFieldDelegate
132
137
133
- ` ICTokenField ` currently notifies its delegate the following events:
138
+ ` TokenField ` currently notifies its delegate the following events:
134
139
135
140
``` 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 )
143
148
```
144
149
145
150
The displayed delimiter string can be customized by:
146
151
147
152
``` 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 ()
149
187
```
150
188
151
189
### Documentation
0 commit comments