A.storyboard control version 1.label2.textfield a.keyboard Type account: Number Pad Password: number and punctuation B.pla Ceholder: Hint text c.clear button:appears with editing clear button d.secure text Entry: password format input 3.button
1 @interfaceViewcontroller ()2@property (Weak, nonatomic) Iboutlet Uitextfield *Qqfield;3@property (Weak, nonatomic) Iboutlet Uitextfield *Pwdfield;4 5-(ibaction) login;6 7 @end8 9 @implementationViewcontrollerTen One- (void) Viewdidload { A [Super Viewdidload]; - //additional setup after loading the view, typically from a nib. - } the -- (void) didreceivememorywarning { - [Super didreceivememorywarning]; - //Dispose of any resources the can be recreated. + } - +-(ibaction) Login { ANSLog (@"%@ - %@", Self.qqField.text, self.pwdField.text); at } - @endB. Creating a button through code
1 @interfaceViewcontroller ()2 3- (void) AddLabel;4- (void) Addtextfield;5- (void) Addloginbutton;6- (void) login;7 8 @end9 Ten @implementationViewcontroller One A- (void) Viewdidload { - [Super Viewdidload]; - //additional setup after loading the view, typically from a nib. the - [self addlabel]; - [self Addtextfield]; - [self Addloginbutton]; + } - +- (void) didreceivememorywarning { A [Super didreceivememorywarning]; at //Dispose of any resources the can be recreated. - } - -- (void) AddLabel { -UILabel *titlelabel = [[UILabel alloc] Initwithframe:cgrectmake (0, $, Self.view.frame.size.width, +)]; - [Titlelabel Settextalignment:nstextalignmentcenter]; inTitlelabel.text =@"QQ Landing Interface 2"; - [Self.view Addsubview:titlelabel]; to +UILabel *qqlabel = [[UILabel alloc] Initwithframe:cgrectmake ( -, the, -, +)]; -Qqlabel.text =@"QQ"; the [Self.view Addsubview:qqlabel]; * $UILabel *pwdlabel = [[UILabel alloc] Initwithframe:cgrectmake ( -,131, the, +)];Panax NotoginsengPwdlabel.text =@"Password"; - [Self.view Addsubview:pwdlabel]; the } + A- (void) Addtextfield { theUitextfield *qqfield = [[Uitextfield alloc] Initwithframe:cgrectmake (109, the,151, -)]; +Qqfield.placeholder =@"Please enter QQ account number"; - [Qqfield setclearbuttonmode:uitextfieldviewmodewhileediting]; $ [Qqfield Setkeyboardtype:uikeyboardtypenumberpad]; $ [Qqfield Setborderstyle:uitextborderstyleroundedrect]; -[Qqfield Settag:1]; - [Self.view Addsubview:qqfield]; the -Uitextfield *pwdfield = [[Uitextfield alloc] Initwithframe:cgrectmake (109,127,151, -)];WuyiPwdfield.placeholder =@"Please enter the QQ password"; the [Pwdfield Setsecuretextentry:yes]; - [Pwdfield setkeyboardtype:uikeyboardtypenumbersandpunctuation]; Wu [Pwdfield setclearbuttonmode:uitextfieldviewmodewhileediting]; - [Pwdfield Setborderstyle:uitextborderstyleroundedrect]; About[Pwdfield Settag:2]; $ [Self.view Addsubview:pwdfield]; - } - -- (void) Addloginbutton { A //Note If you use Uibuttontypecustom, the default background color and Titlecolor are white and do not show +UIButton *loginbutton =[UIButton Buttonwithtype:uibuttontypesystem]; the -CGRect Loginrect = CGRectMake (145,177, -, -); $Loginbutton.frame =Loginrect; the[Loginbutton Settitle:@"Login"Forstate:uicontrolstatenormal]; the [Loginbutton addtarget:self action: @selector (login) forcontrolevents:uicontroleventtouchupinside]; the the [Self.view Addsubview:loginbutton]; - } in the #pragmaMark-action the- (void) Login { AboutUitextfield *qqfield = [Self.view viewwithtag:1]; theUitextfield *pwdfield = [Self.view viewwithtag:2]; the theNSLog (@"Login---->%@-%@", Qqfield.text, pwdfield.text); + } - @end
[iOS base Control-3.1] QQ Landing Interface