Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // LoginViewController.swift
- // Lieferschein
- //
- // Created by Sevgjan on 5/24/19.
- // Copyright © 2019 Swiss IT-Factory. All rights reserved.
- //
- import UIKit
- class LoginViewController: UIViewController {
- @IBOutlet weak var lblLieferschein: UILabel!
- @IBOutlet weak var lblLieferscheinCenterConstraint: NSLayoutConstraint! //-180
- @IBOutlet weak var txtUsername: UITextField!
- @IBOutlet weak var txtPassword: UITextField!
- @IBOutlet weak var btnLogin: UIButton!
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do any additional setup after loading the view.
- setup(textField: txtUsername, withImage: UIImage(named: "user") ?? UIImage())
- setup(textField: txtPassword, withImage: UIImage(named: "password") ?? UIImage())
- lblLieferschein.font = isRunningOnIpad() ? UIFont.systemFont(ofSize: 70, weight: .semibold) : UIFont.systemFont(ofSize: 40, weight: .semibold)
- lblLieferscheinCenterConstraint.constant = isRunningOnIpad() ? -180 : 0
- }
- @IBAction func versionInfo(_ sender: Any) {
- let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"]
- if let versionNumber = version as? String {
- let alert = UIAlertController.init(title: "Arbeitsrapport \nVersion \(versionNumber)", message: "Swiss IT-Factory", preferredStyle: .alert)
- alert.addAction(UIAlertAction(title: "Erledigt", style: .default, handler: { (action) in
- alert.dismiss(animated: true, completion: nil)
- }))
- self.present(alert, animated: true, completion: nil)
- }
- }
- func setup(textField: UITextField, withImage: UIImage) {
- let blankView = UIView(frame: CGRect(x: 0, y: 0, width: 35, height: textField.frame.height))
- let userIcon = UIImageView(image: withImage)
- userIcon.contentMode = .scaleAspectFit
- userIcon.center = blankView.center
- blankView.backgroundColor = .clear
- blankView.addSubview(userIcon)
- textField.leftView = blankView
- textField.leftViewMode = .always
- }
- @IBAction func loginAction(_ sender: Any) {
- performSegue(withIdentifier: "showMain", sender: self)
- }
- /*
- // MARK: - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
- // Get the new view controller using segue.destination.
- // Pass the selected object to the new view controller.
- }
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement