Advertisement
Guest User

Untitled

a guest
May 24th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. //
  2. // LoginViewController.swift
  3. // Lieferschein
  4. //
  5. // Created by Sevgjan on 5/24/19.
  6. // Copyright © 2019 Swiss IT-Factory. All rights reserved.
  7. //
  8.  
  9. import UIKit
  10.  
  11. class LoginViewController: UIViewController {
  12.  
  13. @IBOutlet weak var lblLieferschein: UILabel!
  14. @IBOutlet weak var lblLieferscheinCenterConstraint: NSLayoutConstraint! //-180
  15. @IBOutlet weak var txtUsername: UITextField!
  16. @IBOutlet weak var txtPassword: UITextField!
  17. @IBOutlet weak var btnLogin: UIButton!
  18.  
  19. override func viewDidLoad() {
  20. super.viewDidLoad()
  21.  
  22. // Do any additional setup after loading the view.
  23. setup(textField: txtUsername, withImage: UIImage(named: "user") ?? UIImage())
  24. setup(textField: txtPassword, withImage: UIImage(named: "password") ?? UIImage())
  25.  
  26. lblLieferschein.font = isRunningOnIpad() ? UIFont.systemFont(ofSize: 70, weight: .semibold) : UIFont.systemFont(ofSize: 40, weight: .semibold)
  27. lblLieferscheinCenterConstraint.constant = isRunningOnIpad() ? -180 : 0
  28. }
  29.  
  30. @IBAction func versionInfo(_ sender: Any) {
  31. let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"]
  32. if let versionNumber = version as? String {
  33. let alert = UIAlertController.init(title: "Arbeitsrapport \nVersion \(versionNumber)", message: "Swiss IT-Factory", preferredStyle: .alert)
  34. alert.addAction(UIAlertAction(title: "Erledigt", style: .default, handler: { (action) in
  35. alert.dismiss(animated: true, completion: nil)
  36. }))
  37.  
  38. self.present(alert, animated: true, completion: nil)
  39. }
  40. }
  41.  
  42. func setup(textField: UITextField, withImage: UIImage) {
  43. let blankView = UIView(frame: CGRect(x: 0, y: 0, width: 35, height: textField.frame.height))
  44. let userIcon = UIImageView(image: withImage)
  45. userIcon.contentMode = .scaleAspectFit
  46. userIcon.center = blankView.center
  47. blankView.backgroundColor = .clear
  48. blankView.addSubview(userIcon)
  49.  
  50. textField.leftView = blankView
  51. textField.leftViewMode = .always
  52. }
  53.  
  54. @IBAction func loginAction(_ sender: Any) {
  55. performSegue(withIdentifier: "showMain", sender: self)
  56. }
  57.  
  58. /*
  59. // MARK: - Navigation
  60.  
  61. // In a storyboard-based application, you will often want to do a little preparation before navigation
  62. override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  63. // Get the new view controller using segue.destination.
  64. // Pass the selected object to the new view controller.
  65. }
  66. */
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement