美文网首页
简单的登录注册界面--Swift

简单的登录注册界面--Swift

作者: Shero靳 | 来源:发表于2016-11-21 17:17 被阅读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: 0.6000000238, green: 0.6000000238, blue: 0.6000000238, alpha: 1)

self.window?.makeKeyAndVisible()

self.window?.rootViewController = UIViewController()

let aImageView = UIImageView(frame: CGRect(x: (self.window?.bounds.size.width)! / 2 - 57, y: 50, width: 120, height: 120))

aImageView.image = UIImage(named:"5.png")

//切圆角

aImageView.layer.cornerRadius = 60

aImageView.layer.masksToBounds = true

self.window?.addSubview(aImageView)

let label1 = UILabel(frame: CGRect(x: 50, y: 230, width: 70, height: 40))

label1.backgroundColor = #colorLiteral(red: 0.501960814, green: 0.501960814, blue: 0.501960814, alpha: 1)

label1.text = "账号"

label1.textColor = #colorLiteral(red: 0.6000000238, green: 0.6000000238, blue: 0.6000000238, alpha: 1)

label1.font = UIFont.systemFont(ofSize: 20.0)

label1.layer.cornerRadius = 9

label1.layer.masksToBounds = true

label1.textAlignment = .center

self.window?.addSubview(label1)

let label2 = UILabel(frame: CGRect(x: 50, y: 300, width: 70, height: 40))

label2.backgroundColor = #colorLiteral(red: 0.501960814, green: 0.501960814, blue: 0.501960814, alpha: 1)

label2.text = "密码"

label2.font = UIFont.systemFont(ofSize: 20.0)

label2.layer.cornerRadius = 9

label2.layer.masksToBounds = true

label2.textColor = #colorLiteral(red: 0.6000000238, green: 0.6000000238, blue: 0.6000000238, alpha: 1)

label2.textAlignment = .center

self.window?.addSubview(label2)

let textField1 = UITextField(frame: CGRect(x: 150, y: 230, width: 200, height: 40))

textField1.backgroundColor = #colorLiteral(red: 0.501960814, green: 0.501960814, blue: 0.501960814, alpha: 1)

textField1.borderStyle = .roundedRect//textField切圆角

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

textField1.clearsOnBeginEditing = true

textField1.font = UIFont.systemFont(ofSize: 20.0)

self.window?.addSubview(textField1)

let textField2 = UITextField(frame: CGRect(x: 150, y: 300, width: 200, height: 40))

textField2.backgroundColor = #colorLiteral(red: 0.501960814, green: 0.501960814, blue: 0.501960814, alpha: 1)

textField1.borderStyle = .roundedRect

textField2.placeholder = "请输入密码"

textField2.clearsOnBeginEditing = true

textField2.isSecureTextEntry = true

textField2.font = UIFont.systemFont(ofSize: 20.0)

self.window?.addSubview(textField2)

let button1 = UIButton(frame: CGRect(x: 70, y: 370, width: 100, height: 40))

button1.backgroundColor = #colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1)

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

button1.setTitleColor(#colorLiteral(red: 0.6000000238, green: 0.6000000238, blue: 0.6000000238, alpha: 1), for: .normal)

button1.setTitleColor(#colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1), for: .highlighted)

button1.layer.cornerRadius = 9

button1.layer.masksToBounds = true

button1.titleLabel?.font = UIFont .systemFont(ofSize: 20.0)

self.window?.addSubview(button1)

let button2 = UIButton(frame: CGRect(x: 230, y: 370, width: 100, height: 40))

button2.backgroundColor = #colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1)

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

button2.setTitleColor(#colorLiteral(red: 0.6000000238, green: 0.6000000238, blue: 0.6000000238, alpha: 1), for: .normal)

button2.setTitleColor(#colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1), for: .highlighted)

button2.layer.cornerRadius = 9

button2.layer.masksToBounds = true

button2.titleLabel?.font = UIFont .systemFont(ofSize: 20.0)

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:.

}

}

相关文章

  • 简单的登录注册界面--Swift

    import UIKit @UIApplicationMain class AppDelegate: UIResp...

  • 2018-07-09

    登录及注册 登录界面 登录界面代码 管理员界面 管理员界面代码 设置父子窗口 注册界面 注册界面代码 调用参数 查...

  • 2018-07-09

    考勤系统的登录与录入 登录界面 1)登录界面代码 录入界面 1)录入界面代码 注册界面 1)注册信息代码 1)数据...

  • 考勤系统

    考勤系统功能实现——登录、注册 1、界面 1.1登录界面 1.2注册界面 2、主要代码 2.1登录主要代码 2.2...

  • 移动端UI界面设计之-注册登录

    注册登录是移动端UI界面设计中最基础的板块之一,界面看似简单,但是想设计一个让人眼前一亮的注册登录界面并非易事。今...

  • day11- 作业

    ==============一.注册界面================ ==============二.登录界面...

  • Day27

    登录注册首页界面

  • 实现前后端登录注册界面

    本篇博客讲解如何实现前后端的简单登录注册界面,后端代码由node.js实现,主要阐述登录注册时网页工作原理。感兴趣...

  • 微信开发-技术文档(1)10.8-10.15

    ## 1.前端页面构建 #### 登录注册界面仿造网页微信的登录界面,把二维码扫描登录改成了双面翻转的登录注册板块...

  • Android项目实战系列—基于博学谷(三)注册与登录模块

    由于这个模块内容较多,篇幅较长,请耐心阅读。 注册与登录模块分为三个部分 欢迎界面 注册界面 登录界面 一、欢迎界...

网友评论

      本文标题:简单的登录注册界面--Swift

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