import UIKit@UIApplicationMainclass AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { self.window = UIWindow(frame:UIScreen.main.bounds) self.window?.backgroundColor = #colorLiteral(red: 0.4745098054, green: 0.8392156959, blue: 0.9764705896, alpha: 1) self.window?.makeKeyAndVisible() self.window?.rootViewController = UIViewController() let aImageView = UIImageView(frame:CGRect(x: 150, y: 40, width: 100, height: 100)) aImageView.image = UIImage(named:"aaa") aImageView.layer.masksToBounds = true aImageView.layer.cornerRadius = 50 self.window?.addSubview(aImageView) let lable1 = UILabel(frame:CGRect(x: 20, y: 200, width: 80, height: 40)) lable1.backgroundColor = #colorLiteral(red: 0.5568627715, green: 0.3529411852, blue: 0.9686274529, alpha: 1) let lable2 = UILabel(frame:CGRect(x: 20, y: 260, width: 80, height: 40)) lable2.backgroundColor = #colorLiteral(red: 0.5568627715, green: 0.3529411852, blue: 0.9686274529, alpha: 1) lable1.text = "账号" lable1.textColor = #colorLiteral(red: 0.721568644, green: 0.8862745166, blue: 0.5921568871, alpha: 1) lable1.textAlignment = .center lable1.layer.masksToBounds = true lable1.layer.cornerRadius = 5 lable2.text = "密码" lable2.textColor = #colorLiteral(red: 0.721568644, green: 0.8862745166, blue: 0.5921568871, alpha: 1) lable2.textAlignment = .center lable2.layer.masksToBounds = true lable2.layer.cornerRadius = 5 self.window?.addSubview(lable1) self.window?.addSubview(lable2) let textField1 = UITextField(frame:CGRect(x: 160, y: 200, width: 200, height: 40)) textField1.backgroundColor = #colorLiteral(red: 0.9568627477, green: 0.6588235497, blue: 0.5450980663, alpha: 1) textField1.borderStyle = .roundedRect textField1.text = "输入的内容" textField1.placeholder = "请输入用户名" textField1.clearsOnBeginEditing = true let textField2 = UITextField(frame:CGRect(x: 160, y: 260, width: 200, height: 40)) textField2.backgroundColor = #colorLiteral(red: 0.9568627477, green: 0.6588235497, blue: 0.5450980663, alpha: 1) textField2.borderStyle = .roundedRect textField2.text = "输入的内容" textField2.placeholder = "请输入密码" textField2.clearsOnBeginEditing = true self.window?.addSubview(textField1) self.window?.addSubview(textField2) let button1 = UIButton(type:.custom) button1.frame = CGRect(x: 20, y: 330, width: 100, height: 40) button1.backgroundColor = UIColor.gray button1.setTitle("登录", for: .normal) button1.layer.masksToBounds = true button1.layer.cornerRadius = 5 let button2 = UIButton(type:.custom) button2.frame = CGRect(x: 280, y: 330, width: 100, height: 40) button2.backgroundColor = UIColor.gray button2.setTitle("注册", for: .normal) button2.layer.masksToBounds = true button2.layer.cornerRadius = 5 self.window?.addSubview(button1) self.window?.addSubview(button2) return true } override func touchesBegan(_ touches: Set, with event: UIEvent?) {
let textField1 = self.window?.viewWithTag(200)
textField1?.resignFirstResponder()
let textField2 = self.window?.viewWithTag(200)
textField2?.resignFirstResponder()
}
}