Together项目IOS平台开发04

今天完成的是和上次的邮箱登录界面差不多的一个注册界面,主要包含了“用户名输入框”、“邮箱输入框”、“密码输入框”、“密码确认框”以及一个“注册”按钮。我使用的是4个UITextField以及一个UIButton。这个在设计上和之前的并没有什么差别,只是修改了下输入框内的提示文字,修改了位置。

另外一点在输入的时候,我修改了输入问题的安全属性,在密码的2个输入当中,让正常的文字以圆点方式显示,更加符合我们日常注册的习惯。

本来是想写一个判断两次密码是否相同的函数的,但是#selector中没发多元传参。可能会在下次予以实现。另外就是一样的,为了整个界面的美观,给了这个注册界面一个背景图片。

整体上来讲,使用的技术没有多大差别,通过点击上次的登录界面,就可以跳转到这次的注册界面。

连同上次修改过的登录界面和这次的注册界面的截图如下!




以下是我的代码

//
//  RegisterViewController.swift
//  FinalTest
//
//  Created by 沈力同 on 2017/5/10.
//  Copyright © 2017年 沈力同. All rights reserved.
//

import UIKit



class RegisterViewController: UIViewController ,UITextFieldDelegate{
    
    let screenSizeWidth = UIScreen.main.bounds.size.width
    
    let screenSizeHeight = UIScreen.main.bounds.size.height
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.view.backgroundColor = UIColor.white
        
        let image_BG = UIImageView(image:UIImage(named:"IMG03.jpg"))
        
        image_BG.frame = CGRect(x: 0, y: 0, width: screenSizeWidth, height: screenSizeHeight)
        
        self.view.addSubview(image_BG)
        
        //用户名框
        let text00 = UITextField(frame:CGRect(x:5, y:127, width:screenSizeWidth-10, height:30))
        
        text00.borderStyle = UITextBorderStyle.roundedRect
        
        text00.alpha = 0.75
        
        text00.placeholder = "请输入你的用户名"
        
        text00.adjustsFontSizeToFitWidth=true  //当文字超出文本框宽度时,自动调整文字大小
        
        text00.minimumFontSize=14  //最小可缩小的字号
    
        text00.clearButtonMode = .whileEditing  //编辑时出现清除按钮
        
        text00.textAlignment = .center //水平居中对齐
        
        self.view.addSubview(text00)

        //邮箱输入框
        let text01 = UITextField(frame:CGRect(x:5, y:180, width:screenSizeWidth-10, height:30))
        
        text01.borderStyle = UITextBorderStyle.roundedRect
        
        text01.alpha = 0.75
        
        text01.placeholder = "请输入你想要注册的邮箱"
        
        text01.adjustsFontSizeToFitWidth=true  //当文字超出文本框宽度时,自动调整文字大小
        
        text01.minimumFontSize=14  //最小可缩小的字号
        
        text01.clearButtonMode = .whileEditing  //编辑时出现清除按钮
        
        text01.textAlignment = .center //水平居中对齐
        
        self.view.addSubview(text01)
    
        //密码输入框
        let text02 = UITextField(frame:CGRect(x:5, y:233, width:screenSizeWidth-10, height:30))
        
        text02.borderStyle = UITextBorderStyle.roundedRect
        
        text02.alpha = 0.75
        
        text02.placeholder = "请输入你的登录密码"
        
        text02.adjustsFontSizeToFitWidth=true  //当文字超出文本框宽度时,自动调整文字大小
        
        text02.minimumFontSize=14  //最小可缩小的字号
        
        text02.clearButtonMode = .whileEditing  //编辑时出现清除按钮
        
        text02.textAlignment = .center //水平居中对齐
        
        text02.isSecureTextEntry = true;
        
        text02.delegate = self
        
        self.view.addSubview(text02)
        
        //密码确认框
        let text03 = UITextField(frame:CGRect(x:5, y:286, width:screenSizeWidth-10, height:30))
        
        text03.borderStyle = UITextBorderStyle.roundedRect
        
        text03.alpha = 0.75
        
        text03.placeholder = "请再次输入你的密码"
        
        text03.adjustsFontSizeToFitWidth=true  //当文字超出文本框宽度时,自动调整文字大小
        
        text03.minimumFontSize=14  //最小可缩小的字号
        
        text03.clearButtonMode = .whileEditing  //编辑时出现清除按钮
        
        text03.textAlignment = .center //水平居中对齐
        
        text03.isSecureTextEntry = true;
        
        text03.delegate = self
        
        self.view.addSubview(text03)

        //注册按钮
        let button_register:UIButton = UIButton(type:.system)
        
        button_register.layer.borderColor = UIColor.gray.cgColor;
        
        button_register.layer.borderWidth = 2;
        
        button_register.layer.cornerRadius = 5;
        
        button_register.frame = CGRect(x:5, y:339, width:screenSizeWidth-10, height:50)
        
        button_register.setTitle("注册", for:.normal)
        
        button_register.addTarget(self, action: #selector(RegisterViewController.click_register), for: .touchUpInside)
        
        self.view.addSubview(button_register)
        
        button_register.setTitleColor(UIColor.white, for: .normal) //普通状态下文字的颜色
        
        button_register.backgroundColor = UIColor.gray
    
        
       
    
    }
    
    func click_register(text02:UITextField,text03:UITextField){
        
        if (text02.text != text03.text) {
        
            let alertController = UIAlertController(title: "提示!",message: "两次密码不一致!",preferredStyle: .alert)
            
            let cancelAction = UIAlertAction(title: "确定", style: .cancel, handler: nil)
            
            alertController.addAction(cancelAction)
            
            self.present(alertController, animated: true, completion: nil)

        }
        if (text02.text == text03.text)
        {
//            let RegisterView = RegisterViewController()
//            
//            self.navigationController?.pushViewController(RegisterView, animated: true)
        
        }
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值