用基本控件简单地仿QQ登录界面

//  Created by 妖精的尾巴 on 15-8-14.

//  Copyright (c) 2015 妖精的尾巴. All rights reserved.

//


#import "ViewController.h"


@interface ViewController ()

{

    UILabel* backgroundLabel;//背景label

    UILabel* label1;//QQlabel

    UILabel* label2;//密码label

    UILabel* label3;//最下面label

    UITextField* textField1;//输入QQ号的UITextField

    UITextField* textField2;//输入QQ密码的UITextField

}

@end


@implementation ViewController


- (void)viewDidLoad

{

    [super viewDidLoad];

    [self createLabel];

    [self createTextField];

    [self createButton];

}

-(void)createLabel

{

    backgroundLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 130)];

    backgroundLabel.backgroundColor=[UIColor orangeColor];

    backgroundLabel.userInteractionEnabled=YES;

    [self.view addSubview:backgroundLabel];

    

    

    label1=[[UILabel alloc]initWithFrame:CGRectMake(20,30, 80, 30)];

    label1.text=@"QQ:";

    label1.textColor=[UIColor blackColor];

    label1.font=[UIFont systemFontOfSize:17];

    [backgroundLabel addSubview:label1];

    

    label2=[[UILabel alloc]initWithFrame:CGRectMake(20,70, 80, 30)];

    label2.text=@"密码:";

    label2.textColor=[UIColor blackColor];

    label2.font=[UIFont systemFontOfSize:17];

    [backgroundLabel addSubview:label2];

    

    label3=[[UILabel alloc]initWithFrame:CGRectMake(0, 200, 320, 30)];

    label3.backgroundColor=[UIColor greenColor];

    [self.view addSubview:label3];


}

-(void)createTextField

{

    textField1=[[UITextField alloc]initWithFrame:CGRectMake(80, 30, 190, 30)];

    textField1.borderStyle=UITextBorderStyleRoundedRect;

    textField1.font=[UIFont systemFontOfSize:14];

    textField1.placeholder=@"请输入QQ号码";

    textField1.keyboardType=UIKeyboardTypeNumberPad;

    [backgroundLabel addSubview:textField1];

    

    textField2=[[UITextField alloc]initWithFrame:CGRectMake(80, 70, 190, 30)];

    textField2.borderStyle=UITextBorderStyleRoundedRect;

    textField2.font=[UIFont systemFontOfSize:14];

    textField2.placeholder=@"请输入QQ密码";

    textField2.keyboardType=UIKeyboardTypeNumberPad;

    textField2.secureTextEntry=YES;

    [backgroundLabel addSubview:textField2];


}

-(void)createButton

{

    UIButton *btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];

    btn.backgroundColor=[UIColor blueColor];

    btn.layer.cornerRadius=10;

    [btn setTitle:@"登录" forState:UIControlStateNormal];

    btn.titleLabel.font=[UIFont systemFontOfSize:17];

    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    btn.frame=CGRectMake(110, 145, 90, 40);

    [btn  addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:btn];

}

-(void)btnClick

{

    NSLog(@"登录按钮被点击");

    /**

     *以下两句代码让键盘放弃第一响应者,自己退下

     */

    [textField1 resignFirstResponder];

    [textField2 resignFirstResponder];

    label3.text=[NSString stringWithFormat:@"QQ号为:%@的密码是:%@",textField1.text,textField2.text];

}


195654_sddU_2332019.png

195715_Qve6_2332019.png

转载于:https://my.oschina.net/iOSliuhui/blog/492558

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值