美文网首页
页面小布局

页面小布局

作者: 浅笑嫣然9611 | 来源:发表于2016-11-21 15:55 被阅读0次

    import UIKit

    @UIApplicationMain

    class 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: 1, green: 1, blue: 1, alpha: 1)

    //成为主屏幕并可见

    self.window?.makeKeyAndVisible()

    self.window?.rootViewController = UIViewController()

    //图片的设置

    let image = UIImageView(frame: CGRect(x: 142, y: 30, width: 140, height: 140))

    image.backgroundColor = #colorLiteral(red: 0.9254902005, green: 0.2352941185, blue: 0.1019607857, alpha: 1)

    image.layer.cornerRadius = 70

    image.layer.masksToBounds = true

    image.image = UIImage(named:"1.jpg")

    self.window?.addSubview(image)

    //账户

    let lable1 = UILabel(frame: CGRect(x: 20, y: 200, width: 60, height: 60))

    lable1.backgroundColor = #colorLiteral(red: 0.9686274529, green: 0.78039217, blue: 0.3450980484, alpha: 1)

    lable1.text = "账户"

    lable1.textColor = #colorLiteral(red: 0.5568627715, green: 0.3529411852, blue: 0.9686274529, alpha: 1)

    lable1.textAlignment = .center

    lable1.layer.cornerRadius = 5

    lable1.layer.masksToBounds = true

    self.window?.addSubview(lable1)

    //密码

    let lable2 = UILabel(frame: CGRect(x: 20, y: 300, width: 60, height: 60))

    lable2.backgroundColor = #colorLiteral(red: 0.9686274529, green: 0.78039217, blue: 0.3450980484, alpha: 1)

    lable2.text = "密码"

    lable2.textColor = #colorLiteral(red: 0.5568627715, green: 0.3529411852, blue: 0.9686274529, alpha: 1)

    lable2.textAlignment = .center

    //切圆角

    lable2.layer.cornerRadius = 5

    lable2.layer.masksToBounds = true

    self.window?.addSubview(lable2)

    //请输入用户名

    let text1 = UITextField(frame: CGRect(x: 120, y: 200, width: 200, height: 60))

    text1.backgroundColor = #colorLiteral(red: 0.721568644, green: 0.8862745166, blue: 0.5921568871, alpha: 1)

    text1.placeholder = "请输入用户名"

    text1.borderStyle = .roundedRect

    self.window?.addSubview(text1)

    //请输入密码

    let text2 = UITextField(frame: CGRect(x: 120, y: 300, width: 200, height: 60))

    text2.backgroundColor = #colorLiteral(red: 0.721568644, green: 0.8862745166, blue: 0.5921568871, alpha: 1)

    text2.placeholder = "请输入密码"

    //密码为隐文

    text2.isSecureTextEntry = true

    text2.borderStyle = .roundedRect

    self.window?.addSubview(text2)

    //登录按钮

    let button1 = UIButton(frame: CGRect(x: 50, y: 400, width: 80, height: 60))

    button1.backgroundColor = #colorLiteral(red: 0.9098039269, green: 0.4784313738, blue: 0.6431372762, alpha: 1)

    button1.layer.cornerRadius = 5

    button1.layer.masksToBounds = true

    button1.setTitle("登录", for: .normal)

    self.window?.addSubview(button1)

    //注册按钮

    let button2 = UIButton(frame: CGRect(x: 200, y: 400, width: 80, height: 60))

    button2.backgroundColor = #colorLiteral(red: 0.9098039269, green: 0.4784313738, blue: 0.6431372762, alpha: 1)

    button2.layer.cornerRadius = 5

    button2.layer.masksToBounds = true

    button2.setTitle("注册", for: .normal)

    self.window?.addSubview(button2)

    return true

    }

    func applicationWillResignActive(_ application: UIApplication) {

    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.

    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.

    }

    func applicationDidEnterBackground(_ application: UIApplication) {

    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.

    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

    }

    func applicationWillEnterForeground(_ application: UIApplication) {

    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.

    }

    func applicationDidBecomeActive(_ application: UIApplication) {

    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

    }

    func applicationWillTerminate(_ application: UIApplication) {

    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

    }

    }

    相关文章

      网友评论

          本文标题:页面小布局

          本文链接:https://www.haomeiwen.com/subject/nluupttx.html