#import "ViewController.h"@interfaceViewcontroller () @property (nonatomic, weak) Uitextfield*_textname, @property (nonatomic, weak) Uitextfield*_textpassword;@endHttp://www.cnblogs.com/pocket-mood/p/4331303.html@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; /** QQ*/UILabel*labname =[[UILabel alloc] init]; Labname.frame= CGRectMake ( the, in, +, the); Labname.text=@"QQ:"; Labname.textcolor=[Uicolor Bluecolor]; [Self.view Addsubview:labname]; /** Password*/UILabel*labpassword =[[UILabel alloc] init]; Labpassword.frame= CGRectMake ( the, the, +, the); Labpassword.text=@"Password:"; Labpassword.textcolor=[Uicolor Redcolor]; [Self.view Addsubview:labpassword]; /** QQ Text*/Uitextfield*textname =[[Uitextfield alloc] init]; Textname.frame= CGRectMake ( -, -,260, +); //Set text box style (rounded rectangle)Textname.borderstyle =Uitextborderstyleroundedrect; //set the placeholder content that the text box displays when there is no contentTextname.placeholder =@"Please enter QQ number"; Textname.textcolor=[Uicolor Blackcolor]; //set keyboard as numeric keypad inputTextname.keyboardtype =Uikeyboardtypenumberpad; //all delete icons appear to the right when setting editTextname.clearbuttonmode =uitextfieldviewmodewhileediting; [Self.view Addsubview:textname]; //to enable _textname to invoke control properties laterSelf._textname =Textname; /** Password Text*/Uitextfield*textpassword =[[Uitextfield alloc] init]; Textpassword.frame= CGRectMake ( -, -,260, +); Textpassword.borderstyle=Uitextborderstyleroundedrect; Textpassword.placeholder=@"Please enter your password"; Textpassword.textcolor=[Uicolor Redcolor]; //set text to password status, text all to point displayTextpassword.securetextentry =YES; Textpassword.clearbuttonmode=uitextfieldviewmodewhileediting; [Self.view Addsubview:textpassword]; Self._textpassword=Textpassword; /** Login Button*/UIButton*btnregiste =[[UIButton alloc] init]; Btnregiste.frame= CGRectMake ( the,290, -, -); [Btnregiste settitle:@"Login"Forstate:uicontrolstatenormal]; [Btnregiste Settitlecolor:[uicolor Whitecolor] forstate:uicontrolstatenormal]; [Btnregiste Settitlecolor:[uicolor Redcolor] forstate:uicontrolstatehighlighted]; [Btnregiste Setbackgroundcolor:[uicolor Bluecolor]; //Set button buttons text font style and sizeBtnRegiste.titleLabel.font = [Uifont fontwithname:@"Arial"Size28.0]; //triggering of listener events[Btnregiste addtarget:self Action: @selector (Btnclick:) forcontrolevents:uicontroleventtouchupinside]; [Self.view Addsubview:btnregiste]; }//Monitor- (void) Btnclick: (UIButton *) button{NSLog (@"---- login----\nqq:%@\n password:%@", Self._textname.text,self._textpassword.text); //Exit keyboard State[Self.view Endediting:yes];}@end
(Pure Code) QQ Login Interface: