Created
January 30, 2019 11:36
-
-
Save alexruperez/1b7f943960c91412ebead4f6b05600ad to your computer and use it in GitHub Desktop.
MaterialTextInputOutlined iOS PoC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
platform :ios, '10.3' | |
target 'MaterialTextInputOutlinedPoC' do | |
use_frameworks! | |
pod 'MaterialComponents/TextFields+ColorThemer', '~> 75.0' | |
pod 'MaterialComponents/TextFields+TypographyThemer', '~> 75.0' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Created by Alex Rupérez. | |
// Copyright © 2019 Globant. | |
import UIKit | |
import MaterialComponents.MaterialTextFields | |
class ViewController: UIViewController { | |
@IBOutlet weak var textField: MDCTextField! | |
var textFieldControllerOutlined: MDCTextInputControllerOutlined! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(textFieldShouldReturn(_:)))) | |
let colorScheming: MDCColorScheming = MDCSemanticColorScheme() | |
MDCTextFieldColorThemer.apply(colorScheming, toAllControllersOfClass: MDCTextInputControllerOutlined.self) | |
let typographyScheming: MDCTypographyScheming = MDCTypographyScheme() | |
MDCTextFieldTypographyThemer.apply(typographyScheming, toAllControllersOfClass: MDCTextInputControllerOutlined.self) | |
textField.placeholder = "Text Input Outlined" | |
textField.delegate = self | |
textFieldControllerOutlined = MDCTextInputControllerOutlined(textInput: textField) | |
} | |
} | |
extension ViewController: UITextFieldDelegate { | |
func textFieldShouldReturn(_ textField: UITextField) -> Bool { | |
self.textField.resignFirstResponder() | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment