1. Create a single view of project
2, another new two classes (not necessary) DElabel.h DETextField.h will share the properties and methods are put in the class, special properties and methods directly put in the VC
3. Declare global variables Tfuser tfpass two TextField
4, keyboard close key in a new background, let the background trigger event let two TextField lose control.
===========================
//
Deviewcontroller.m
Testloginpage
//
Created by decade on 14/8/18.
Copyright (c) year decade. All rights reserved.
//
#import "DEViewController.h"
@interface deviewcontroller ()
@end
@implementation Deviewcontroller
-(void) viewdidload
{
[Super viewdidload];
additional setup after loading the view, typically from a nib.
uicontrol *bglb = [[uicontrol alloc]init];
Bglb. frame = [[uiscreen mainscreen]bounds];
[Bglb addTarget:self action:@selector(bgtap) forcontrolevents: Uicontroleventtouchdown];
[self. View addsubview: bglb];
Delabel *lbuser = [[delabel alloc]init];
Lbuser. Frame = CGRectMake (+, +, + );
Lbuser. text = @ " account number:";
[self. View addsubview: lbuser];
Delabel *lbpass = [[delabel alloc]init];
Lbpass. frame = CGRectMake (+, + );
Lbpass. text = @ " password:";
[self. View addsubview: Lbpass];
tfuser = [[detextfield alloc]init];
tfuser. Frame = CGRectMake (+,-- );
tfuser. Placeholder = @ " Please enter account number ";
[Tfuser addtarget:self Action: @selector (BGTAP) forcontrolevents:uicontroleventeditingdidendonexit];
[self. View addsubview:tfuser];
Tfpass = [[Detextfield alloc]init];
Tfpass.frame = CGRectMake (+, + );
Tfpass.placeholder = @ " Please enter password ";
Tfpass.securetextentry = YES;
Tfpass.keyboardtype = Uikeyboardtypenumberpad;
[self. View Addsubview:tfpass];
}
-(void) didreceivememorywarning
{
[Super didreceivememorywarning];
//Dispose of any resources, can be recreated.
}
-(void) touchesended: (Nsset *) touches withevent: (uievent *) event{
if (![ Self.view Isexclusivetouch]) {
[Self.view Resignfirstresponder];
// }
//}
-(void) bgtap{
[Tfuser Resignfirstresponder];
[Tfpass Resignfirstresponder];
}
@end