Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- import Cartography
- class ViewCodeLoginViewController: LoginViewController {
- let userTextField: UITextField = {
- let text = UITextField()
- text.placeholder = "username"
- text.textColor = .black
- return text
- }()
- let passTextField: UITextField = {
- let text = UITextField()
- text.placeholder = "password"
- text.textColor = .black
- return text
- }()
- lazy var loginButton: UIButton = { [weak self] in
- let button = UIButton()
- button.setTitle("login", for: .normal)
- button.addTarget(self, action: #selector(login), for: .touchUpInside)
- button.setTitleColor(.black, for: .normal)
- return button
- }()
- override func loadView() {
- let view = UIView()
- view.addSubview(userTextField)
- view.addSubview(passTextField)
- view.addSubview(loginButton)
- self.view = view
- }
- override func viewDidLoad() {
- constrain(self.view, userTextField, passTextField, loginButton) { view, user, pass, button in
- user.top == view.top + 50
- user.left == view.left + 20
- user.right == view.right - 20
- pass.top == user.bottom + 20
- pass.left == user.left
- pass.right == user.right
- button.top == pass.bottom + 20
- button.right == pass.right
- button.left == pass.left
- button.height == 40
- }
- self.view.backgroundColor = .white
- }
- func login() {
- username = userTextField.text
- password = passTextField.text
- self.delegate?.login(username: self.username!, password: self.password!) { response in
- if response {
- print("user login viewcode")
- } else {
- print("fail to login viewcode")
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment