iOS landing page and keyboard off demo

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.