Skip to content

Commit 0dff815

Browse files
committed
Fix the layout of the example app in iOS 11
1 parent 6c002a1 commit 0dff815

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

Example/CustomizedTokenField.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ class CustomizedTokenField: ICTokenField {
3939
applyCustomizedStyle()
4040
}
4141

42+
override var intrinsicContentSize: CGSize {
43+
return UILayoutFittingExpandedSize
44+
}
45+
4246
}
4347

4448

Example/CustomizedTokenViewController.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,20 @@ class CustomizedTokenViewController: UIViewController, ICTokenFieldDelegate {
5656
cancelBarButton.tintColor = UIColor.white
5757
navigationItem.rightBarButtonItem = cancelBarButton
5858

59-
navigationItem.titleView = tokenField
59+
navigationItem.titleView = {
60+
if #available(iOS 11, *) {
61+
tokenField.translatesAutoresizingMaskIntoConstraints = false
62+
let views = ["field": tokenField]
63+
let metrics = ["padding": 7]
64+
let containerView = UIView()
65+
containerView.addSubview(tokenField)
66+
containerView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[field]-padding-|", options: [], metrics: metrics, views: views))
67+
containerView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-padding-[field]-padding-|", options: [], metrics: metrics, views: views))
68+
return containerView
69+
} else {
70+
return tokenField
71+
}
72+
}()
6073
tokenField.delegate = self
6174
}
6275

Example/ExampleViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class ExampleViewController: UITableViewController {
5454

5555
override func loadView() {
5656
super.loadView()
57+
tableView.rowHeight = 44
5758
tableView.register(ExampleCell.self, forCellReuseIdentifier: String(describing: ExampleCell.self))
5859
tableView.tableFooterView = flipButton
5960
tableView.tableFooterView?.isUserInteractionEnabled = true

0 commit comments

Comments
 (0)