Skip to content

Commit 97e7f3f

Browse files
committed
Update README.md with screenshots and usage
1 parent ea619c4 commit 97e7f3f

1 file changed

Lines changed: 89 additions & 1 deletion

File tree

README.md

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
# ICInputAccessory
22

3-
A customized input accessory UI to dismiss keyboard.
3+
Customized text fields used in the iCook app.
44

55
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
66
[![Build Status](https://travis-ci.org/polydice/ICInputAccessory.svg?branch=develop)](https://travis-ci.org/polydice/ICInputAccessory)
77

8+
### ICKeyboardDismissTextField
9+
10+
* An input accessory view with a button to dismiss keyboard.
11+
12+
### ICTokenField
13+
14+
* A horizontal scrolling UI that groups input texts.
15+
* Easy to add and delete tokens.
16+
* Customizable icon and colors.
17+
18+
<table>
19+
<tr>
20+
<th>ICKeyboardDismissTextField</th>
21+
<th rowspan="2"></th>
22+
<th>ICTokenField</th>
23+
</tr>
24+
<tr>
25+
<th><img src="https://raw.githubusercontent.com/polydice/ICInputAccessory/gh-pages/screenshots/ICKeyboardDismissTextField.png" width="90%" /></th>
26+
<th><img src="https://raw.githubusercontent.com/polydice/ICInputAccessory/gh-pages/screenshots/ICTokenField.png" width="90%" /></th>
27+
</tr>
28+
</table>
29+
830
## Installation
931

1032
### Install via [Carthage](https://github.com/Carthage/Carthage)
@@ -30,3 +52,69 @@ A customized input accessory UI to dismiss keyboard.
3052
```
3153

3254
* For more information, please check out the [Carthage Documentation](https://github.com/Carthage/Carthage#if-youre-building-for-ios).
55+
56+
## Usage
57+
58+
### ICKeyboardDismissTextField
59+
60+
```swift
61+
let textField = ICKeyboardDismissTextField(frame: rect)
62+
```
63+
64+
### ICTokenField
65+
66+
```swift
67+
let tokenField = ICTokenField(frame: rect)
68+
tokenField.delegate = self as? ICTokenFieldDelegate
69+
```
70+
71+
* The characters that completes a token:
72+
73+
```swift
74+
/// Characters that completes a new token, defaults are whitespace and commas.
75+
public var delimiters: [String]
76+
```
77+
78+
* Tokens:
79+
80+
```swift
81+
/// Texts of each created token.
82+
public var texts: [String] { get }
83+
84+
/// Creates a token with the current input text.
85+
public func completeCurrentInputText()
86+
87+
/// Removes the input text and all displayed tokens.
88+
public func resetTokens()
89+
```
90+
91+
* UI customization:
92+
93+
```swift
94+
/// The image on the left of text field.
95+
public var icon: UIImage? { get set }
96+
97+
/// The placeholder with the default color and font.
98+
public var placeholder: String? { get set }
99+
100+
/// The placeholder with customized attributes.
101+
public var attributedPlaceholder: NSAttributedString? { get set }
102+
103+
/// Customized attributes for tokens in the normal state, e.g. NSFontAttributeName and NSForegroundColorAttributeName.
104+
public var normalTokenAttributes: [String : NSObject]? { get set }
105+
106+
/// Customized attributes for tokens in the highlighted state.
107+
public var highlightedTokenAttributes: [String : NSObject]? { get set }
108+
```
109+
110+
See `Example/CustomizedTokenField.swift` for more detail.
111+
112+
#### ICTokenFieldDelegate
113+
114+
`ICTokenField` currently notifies its delegate the following events:
115+
116+
* `tokenFieldDidBeginEditing(_:)`
117+
* `tokenFieldDidEndEditing(_:)`
118+
* `tokenFieldWillReturn(_:)`
119+
* `tokenField(_:didEnterText:)`
120+
* `tokenField(_:didDeleteText:atIndex:)`

0 commit comments

Comments
 (0)