Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // loginController.swift
- // MyFlags
- //
- // Created by Hackeru_Student on 8/15/18.
- // Copyright © 2018 Hackeru_Student. All rights reserved.
- //
- import UIKit
- class loginController: UIViewController {
- @IBOutlet weak var txtUser: UITextField!
- @IBOutlet weak var txtPassword: UITextField!
- override func viewDidLoad() {
- super.viewDidLoad()
- }
- @IBAction func btnLogin(_ sender: Any) {
- let myUser = txtUser.text!
- let myPass = txtPassword.text!
- if myUser == "zeev" && myPass == "12345"
- {
- //intent
- let flagVC = storyboard?.instantiateViewController(withIdentifier: "vcFlag")
- //startActivity
- present(flagVC!, animated: true, completion: nil)
- }
- else
- {
- self.showToast(message: "error in user name or password")
- }
- txtUser.text = ""
- txtPassword.text = ""
- }
- }
- extension UIViewController{
- func showToast(message: String)
- {
- let toastLabel = UILabel(frame: CGRect(x: self.view.frame.size.width/2, y: self.view.frame.size.height-100, width: 150, height: 35))
- toastLabel.backgroundColor = UIColor.black.withAlphaComponent(0.6)
- toastLabel.textColor = UIColor.white
- toastLabel.textAlignment = .center
- toastLabel.text = message
- toastLabel.alpha = 1
- toastLabel.layer.cornerRadius = 10
- toastLabel.clipsToBounds = true
- self.view.addSubview(toastLabel)
- UIView.animate(withDuration: 4.0, delay: 0.1, options: .curveEaseOut, animations: {
- toastLabel.alpha = 0.0
- }, completion: { (isCompleted) in
- toastLabel.alpha = CGFloat(0.0)
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement