Commit 36ce2bb1 by Daniel Dahan

MaterialCollectionViewCell example project, updated

parent e5c999b1
...@@ -50,13 +50,15 @@ class ViewController: UIViewController { ...@@ -50,13 +50,15 @@ class ViewController: UIViewController {
dataSourceItems = [ dataSourceItems = [
MaterialDataSourceItem( MaterialDataSourceItem(
data: [ data: [
"placeholder": "Field Placeholder" "placeholder": "Field Placeholder",
"detailLabelHidden": false
], ],
height: 80 height: 80
), ),
MaterialDataSourceItem( MaterialDataSourceItem(
data: [ data: [
"placeholder": "Field Placeholder" "placeholder": "Field Placeholder",
"detailLabelHidden": false
], ],
height: 80 height: 80
), ),
...@@ -113,8 +115,11 @@ extension ViewController: MaterialCollectionViewDataSource { ...@@ -113,8 +115,11 @@ extension ViewController: MaterialCollectionViewDataSource {
let item: MaterialDataSourceItem = dataSourceItems[indexPath.item] let item: MaterialDataSourceItem = dataSourceItems[indexPath.item]
if let data: Dictionary<String, AnyObject> = item.data as? Dictionary<String, AnyObject> { if let data: Dictionary<String, AnyObject> = item.data as? Dictionary<String, AnyObject> {
cell.pulseColor = nil
cell.pulseScale = false
let textField: TextField = TextField(frame: CGRectMake(16, 16, view.bounds.width - 32, 32)) let textField: TextField = TextField(frame: CGRectMake(16, 16, view.bounds.width - 32, 32))
// textField.delegate = self textField.delegate = self
textField.placeholder = "Email" textField.placeholder = "Email"
textField.placeholderTextColor = MaterialColor.grey.base textField.placeholderTextColor = MaterialColor.grey.base
textField.font = RobotoFont.regularWithSize(20) textField.font = RobotoFont.regularWithSize(20)
...@@ -135,7 +140,7 @@ extension ViewController: MaterialCollectionViewDataSource { ...@@ -135,7 +140,7 @@ extension ViewController: MaterialCollectionViewDataSource {
textField.detailLabel = detailLabel textField.detailLabel = detailLabel
textField.detailLabel!.font = RobotoFont.mediumWithSize(12) textField.detailLabel!.font = RobotoFont.mediumWithSize(12)
textField.detailLabelActiveColor = MaterialColor.red.accent3 textField.detailLabelActiveColor = MaterialColor.red.accent3
// textField.detailLabelAutoHideEnabled = false // Uncomment this line to have manual hiding. // textField.detailLabelAutoHideEnabled = false // Uncomment this line to have manual hiding.
textField.detailLabelHidden = v textField.detailLabelHidden = v
} }
...@@ -148,8 +153,9 @@ extension ViewController: MaterialCollectionViewDataSource { ...@@ -148,8 +153,9 @@ extension ViewController: MaterialCollectionViewDataSource {
/// MaterialCollectionViewDelegate methods. /// MaterialCollectionViewDelegate methods.
extension ViewController : TextFieldDelegate { extension ViewController : TextFieldDelegate {
/// Handle textField return.
func textFieldShouldReturn(textField: UITextField) -> Bool { func textFieldShouldReturn(textField: UITextField) -> Bool {
// handle detail label here. (textField as? TextField)?.detailLabelHidden = false
return true return true
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment