// Created by 妖精的尾巴 on 15-8-14.ide
// Copyright (c) 2015年 妖精的尾巴. All rights reserved.spa
//.net
#import "ViewController.h"3d
@interface ViewController ()orm
{get
UILabel* backgroundLabel;//背景labelstring
UILabel* label1;//QQlabelit
UILabel* label2;//密碼labelio
UILabel* label3;//最下面labelclass
UITextField* textField1;//輸入QQ號的UITextField
UITextField* textField2;//輸入QQ密碼的UITextField
}
@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];
}