Skip to content

Instantly share code, notes, and snippets.

@alexruperez
Created January 30, 2019 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexruperez/1b7f943960c91412ebead4f6b05600ad to your computer and use it in GitHub Desktop.
Save alexruperez/1b7f943960c91412ebead4f6b05600ad to your computer and use it in GitHub Desktop.
MaterialTextInputOutlined iOS PoC
platform :ios, '10.3'
target 'MaterialTextInputOutlinedPoC' do
use_frameworks!
pod 'MaterialComponents/TextFields+ColorThemer', '~> 75.0'
pod 'MaterialComponents/TextFields+TypographyThemer', '~> 75.0'
end
// 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