登陆界面的完善

//
// AppDelegate.m
// UI_Login
//
// Created by dllo on 15/7/30.
// Copyright (c) 2015年 Clare. All rights reserved.
//

import “AppDelegate.h”

@interface AppDelegate ()

@property(nonatomic, retain)UITextField *IDTextField;
@property(nonatomic, retain)UITextField *passWdTextField;
@property(nonatomic, assign)BOOL showButton;
@property(nonatomic, assign)BOOL loginButton;
@property(nonatomic, retain)UIAlertView *alertView;
@property(nonatomic, assign)BOOL cancelButton;
@property(nonatomic, retain)UILabel *showLabelID;
@property(nonatomic, retain)UILabel *showLabelPW;
@property(nonatomic, assign)BOOL headButton;
@property(nonatomic, assign)BOOL exitButton;
@end

@implementation AppDelegate

  • (void)dealloc
    {
    [_window release];
    [_IDTextField release];
    [_passWdTextField release];
    [_alertView release];
    [_showLabelID release];
    [_showLabelPW release];
    [super dealloc];
    }

  • (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    [_window release];

    // 登陆界面
    // 定义一个登录界面,登录界面大小和屏幕的尺寸一样
    UIView *loginView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // 设置登录界面的背景颜色为白色
    loginView.backgroundColor = [UIColor whiteColor];
    // 将登录界面加入到window中
    [self.window addSubview: loginView];
    // 释放登录界面
    [loginView release];
    // 设置登录界面的tag为1000,方便寻找
    loginView.tag = 1000;

    // 定义一个账号标签
    UILabel *IDlabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, 50, 30)];
    // 设置账号标签的背景颜色
    IDlabel.backgroundColor = [UIColor whiteColor];
    // 将账号标签加入到登录界面中
    [loginView addSubview:IDlabel];
    // 释放账号标签
    [IDlabel release];
    // 设置账号标签的名字为”账号”
    IDlabel.text = @”账号”;
    // 设置账号标签的边框宽度为1
    IDlabel.layer.borderWidth = 1;
    // 设置账号标签边框的弧度为5
    IDlabel.layer.cornerRadius = 5;
    // 去掉标签除了边框里面的部分
    IDlabel.layer.masksToBounds= YES;
    // 将标签中的字体居中
    IDlabel.textAlignment = NSTextAlignmentCenter;
    // 定义一条账号输入文本框属性
    self.IDTextField = [[UITextField alloc] initWithFrame:CGRectMake(120, 100, 200, 30)];
    // 设置账号输入框的背景颜色
    self.IDTextField.backgroundColor = [UIColor whiteColor];
    // 设置边框宽度
    self.IDTextField.layer.borderWidth = 1;
    // 设置边框弧度
    self.IDTextField.layer.cornerRadius = 5;
    // 去掉边框多余的部分
    self.IDTextField.layer.masksToBounds = YES;
    // 将账号输入文本框加入到登录界面中
    [loginView addSubview:self.IDTextField];
    // 释放账号输入文本框
    [_IDTextField release];
    // 设置账号输入文本框的占位字符串,即没有输入时的提示字符串
    self.IDTextField.placeholder = @”请输入账号!”;
    // 让账号输入文本框中的文本居中
    self.IDTextField.textAlignment = NSTextAlignmentCenter;

    [self.IDTextField addTarget:self action:@selector(checkID:)forControlEvents:UIControlEventEditingChanged];
    // 账号输入文本框在开始输入的时候清空输入框内容
    self.IDTextField.clearsOnBeginEditing = YES;
    self.IDTextField.delegate = self;

    UILabel *passWdlabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 150, 50, 30)];
    passWdlabel.backgroundColor = [UIColor whiteColor];
    [loginView addSubview:passWdlabel];
    [passWdlabel release];
    passWdlabel.text = @”密码”;
    passWdlabel.textAlignment = NSTextAlignmentCenter;
    passWdlabel.layer.borderWidth = 1;
    passWdlabel.layer.cornerRadius = 5;
    passWdlabel.layer.masksToBounds= YES;

    self.passWdTextField = [[UITextField alloc] initWithFrame:CGRectMake(120, 150, 200, 30)];
    self.passWdTextField.backgroundColor = [UIColor whiteColor];
    self.passWdTextField.layer.borderWidth = 1;
    self.passWdTextField.layer.cornerRadius = 5;
    self.passWdTextField.layer.masksToBounds = YES;
    [loginView addSubview:self.passWdTextField];
    [_passWdTextField release];
    self.passWdTextField.placeholder = @”请输入密码!”;
    self.passWdTextField.textAlignment = NSTextAlignmentCenter;
    self.passWdTextField.secureTextEntry = YES;
    [self.passWdTextField addTarget:self action:@selector(checkPassWd:)forControlEvents:UIControlEventEditingChanged];
    self.passWdTextField.clearsOnBeginEditing = YES;
    self.passWdTextField.delegate = self;

    UIButton *showButton = [UIButton buttonWithType:UIButtonTypeCustom];
    showButton.frame = CGRectMake(85, 150, 50, 30);
    [showButton setImage:[UIImage imageNamed:@”check.png”] forState:UIControlStateNormal];
    [loginView addSubview:showButton];
    [showButton addTarget:self action:@selector(showButton:) forControlEvents:UIControlEventTouchUpInside];
    self.showButton = NO;

    self.showLabelID = [[UILabel alloc] initWithFrame:CGRectMake(330, 100, 30, 30)];
    self.showLabelID.backgroundColor = [UIColor whiteColor];
    [loginView addSubview:self.showLabelID];
    [_showLabelID release];
    _showLabelID.textAlignment = NSTextAlignmentCenter;
    _showLabelID.layer.borderWidth = 1;
    _showLabelID.layer.cornerRadius = 5;
    _showLabelID.layer.masksToBounds = YES;

    self.showLabelPW = [[UILabel alloc] initWithFrame:CGRectMake(330, 150, 30, 30)];
    _showLabelPW.backgroundColor = [UIColor whiteColor];
    [loginView addSubview:_showLabelPW];
    [_showLabelPW release];
    _showLabelPW.textAlignment = NSTextAlignmentCenter;
    _showLabelPW.layer.borderWidth = 1;
    _showLabelPW.layer.cornerRadius = 5;
    _showLabelPW.layer.masksToBounds = YES;

    UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeSystem];
    loginButton.frame = CGRectMake(50, 250, 100, 30);
    loginButton.backgroundColor = [UIColor whiteColor];
    [loginView addSubview:loginButton];
    [loginButton setTitle:@”点击登陆” forState:UIControlStateNormal];
    loginButton.layer.borderWidth = 1;
    loginButton.layer.cornerRadius = 5;
    loginButton.layer.masksToBounds = YES;
    [loginButton addTarget:self action:@selector(loginButton:) forControlEvents:UIControlEventTouchUpInside];
    self.loginButton = YES;

    self.alertView = [[UIAlertView alloc] initWithTitle:@”404,Not Found!;” message:@”账号或密码错误” delegate:self cancelButtonTitle:@”返回” otherButtonTitles:nil, nil];

    UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeSystem];
    cancelButton.frame = CGRectMake(220, 250, 100, 30);
    cancelButton.backgroundColor = [UIColor whiteColor];
    [loginView addSubview:cancelButton];
    [cancelButton setTitle:@”取 消” forState:UIControlStateNormal];
    cancelButton.layer.borderWidth = 1;
    cancelButton.layer.cornerRadius = 5;
    cancelButton.layer.masksToBounds = YES;
    [cancelButton addTarget:self action:@selector(cancelButton:) forControlEvents:UIControlEventTouchUpInside];
    self.cancelButton = YES;

    /// 信息界面
    UIView *informationView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    informationView.backgroundColor = [UIColor whiteColor];

    [self.window addSubview:informationView];
    [informationView release];
    informationView.tag = 1001;
    [self.window bringSubviewToFront:loginView];

    UIButton *headButton = [UIButton buttonWithType:UIButtonTypeCustom];
    headButton.frame = CGRectMake(100, 100, 160, 160);
    [headButton setImage:[UIImage imageNamed:@”11.png”] forState:UIControlStateNormal];
    [informationView addSubview:headButton];
    [headButton addTarget:self action:@selector(headButton:) forControlEvents:UIControlEventTouchUpInside];
    self.headButton = NO;

    UILabel *niceLable = [[UILabel alloc] initWithFrame:CGRectMake(50, 280, 100, 30)];
    niceLable.backgroundColor = [UIColor whiteColor];
    [informationView addSubview:niceLable];
    [niceLable release];
    niceLable.text = @”昵称: 忘の忧”;

    UILabel *levelLable = [[UILabel alloc] initWithFrame:CGRectMake(50, 320, 100, 30)];
    levelLable.backgroundColor = [UIColor whiteColor];
    [informationView addSubview:levelLable];
    [levelLable release];
    levelLable.text = @”等级: 90”;

    UILabel *professionalLable = [[UILabel alloc] initWithFrame:CGRectMake(50, 360, 100, 30)];
    professionalLable.backgroundColor = [UIColor whiteColor];
    [informationView addSubview:professionalLable];
    [professionalLable release];
    professionalLable.text = @”职业: 吟游诗人”;

    UILabel *raceLable = [[UILabel alloc] initWithFrame:CGRectMake(50, 360, 100, 30)];
    raceLable.backgroundColor = [UIColor whiteColor];
    [informationView addSubview:raceLable];
    [raceLable release];
    raceLable.text = @”种族: 精灵族”;

    UIButton *exitButton = [UIButton buttonWithType:UIButtonTypeSystem];
    exitButton.frame = CGRectMake(150, 400, 100, 30);
    exitButton.backgroundColor = [UIColor whiteColor];
    [informationView addSubview:exitButton];
    [exitButton setTitle:@”退 出” forState:UIControlStateNormal];
    exitButton.layer.borderWidth = 1;
    exitButton.layer.cornerRadius = 5;
    exitButton.layer.masksToBounds = YES;
    [exitButton addTarget:self action:@selector(exitButton:) forControlEvents:UIControlEventTouchUpInside];
    self.loginButton = YES;

    return YES;
    }

  • (void)checkID:(UITextField *)IDTextField
    {
    //IDTextField.delegate = self;
    if (IDTextField.text.length > 5 && IDTextField.text.length < 12) {
    if ([IDTextField.text isEqualToString:@”123456”]) {
    self.showLabelID.text = @”√”;
    } else {
    self.showLabelID.text = @”

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值