Skip to content

Commit f785911

Browse files
committed
Show the token field in the example project
1 parent 2585e53 commit f785911

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

Example/Example/ExampleViewController.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ExampleViewController: UIViewController, UITableViewDataSource {
3737
return _tableView
3838
}()
3939

40-
private let types: [UIView.Type] = [ICKeyboardDismissTextField.self]
40+
private let types: [UIView.Type] = [ICKeyboardDismissTextField.self, ICTokenField.self]
4141

4242
// MARK: - Initialization
4343

@@ -53,7 +53,6 @@ class ExampleViewController: UIViewController, UITableViewDataSource {
5353
view.addSubview(tableView)
5454
tableView.frame = view.bounds
5555
tableView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
56-
let _ = ICTokenField()
5756
}
5857

5958
// MARK: - UITableViewDataSource
@@ -70,6 +69,8 @@ class ExampleViewController: UIViewController, UITableViewDataSource {
7069
switch types[section] {
7170
case is ICKeyboardDismissTextField.Type:
7271
return "Dismiss Keyboard"
72+
case is ICTokenField.Type:
73+
return "Text Field with Tokens"
7374
default:
7475
return ""
7576
}
@@ -84,6 +85,19 @@ class ExampleViewController: UIViewController, UITableViewDataSource {
8485
textField.leftView = UIView(frame: CGRect(x: 0, y: 0, width: 15, height: 15))
8586
textField.placeholder = String(type)
8687
(cell as? ExampleCell)?.showcase = textField
88+
89+
case let type as ICTokenField.Type:
90+
let tokenField = type.init()
91+
tokenField.placeholder = String(type)
92+
93+
let container = UIView(frame: cell.bounds)
94+
container.backgroundColor = UIColor(red:0.96, green:0.48, blue:0.4, alpha:1)
95+
96+
tokenField.frame = container.bounds.insetBy(dx: 15, dy: 3)
97+
tokenField.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
98+
container.addSubview(tokenField)
99+
(cell as? ExampleCell)?.showcase = container
100+
87101
default:
88102
break
89103
}

0 commit comments

Comments
 (0)