Skip to content

Instantly share code, notes, and snippets.

@memish
Created August 20, 2019 15:45
Show Gist options
  • Save memish/c7c35d23f684cc75fd97136f974dcb77 to your computer and use it in GitHub Desktop.
Save memish/c7c35d23f684cc75fd97136f974dcb77 to your computer and use it in GitHub Desktop.
//
// ViewController.swift
// Swift5_LoginSystem
//
// Created by Matt M on 8/14/19.
// Copyright © 2019 MM. All rights reserved.
// Step one - get text fields to display programattically
// with styling and formatting positioned on the screen
// Step two - add a button
import UIKit
class ViewController: UIViewController {
let myUsername: UITextField = UITextField(frame: CGRect(x: 10, y: 320, width: 300.00, height: 30.00));
let myPassword: UITextField = UITextField(frame: CGRect(x: 10, y: 360, width: 300.00, height: 30.00));
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
displayLoginFields()
}
func displayLoginFields(){
//ADD USERNAME
// Set UITextField placeholder text
myUsername.placeholder = "Username"
// Set UITextField border style
myUsername.borderStyle = UITextField.BorderStyle.line
// Set UITextField background colour
myUsername.backgroundColor = UIColor.white
// Set UITextField text color
myUsername.textColor = UIColor.blue
// Add UITextField as a subview
self.view.addSubview(myUsername)
// Set UITextField placeholder text
myPassword.placeholder = "password"
myPassword.isSecureTextEntry = true
// Set UITextField border style
myPassword.borderStyle = UITextField.BorderStyle.line
// Set UITextField background colour
myPassword.backgroundColor = UIColor.white
// Set UITextField text color
myPassword.textColor = UIColor.blue
// Add UITextField as a subview
self.view.addSubview(myPassword)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment