//Create buttonUIButton *btn =[[UIButton alloc] init]; Btn.frame= CGRectMake (0,0, -, -); //set the properties of the button in normal state//set a background pictureUIImage *normal = [UIImage imagenamed:@"Btn_01.png"]; [Btn Setbackgroundimage:normal Forstate:uicontrolstatenormal]; [BTN Settitle:@"dot me."Forstate:uicontrolstatenormal]; [btn Settitlecolor:[uicolor Greencolor] forstate:uicontrolstatenormal]; //set the properties of the button in the highlighted StateUIImage *high = [UIImage imagenamed:@"Btn_02.png"]; [Btn Setbackgroundimage:high forstate:uicontrolstatehighlighted]; [BTN Settitle:@"dot me."forstate:uicontrolstatehighlighted]; [btn Settitlecolor:[uicolor Redcolor] forstate:uicontrolstatehighlighted];//Monitor button click[btn addtarget:self Action: @selector (Btnclick:) forcontrolevents:uicontroleventtouchupinside];- (void) Btnclick: (UIButton *) btn{NSLog (@ "———%"p,btn);}//Create a text input boxUitextfield *field =[[Uitextfield alloc] init]; Field.frame= CGRectMake ( -, -, -, -); Field.backgroundcolor=[Uicolor Redcolor];//The X of the midpointCGFloat CenterX = Self.view.frame.size.width *0.5; CGFloat CenterY= Self.view.frame.size.height *0.5' Field.center=Cgpointmake (CenterX, centery);//Set FontField.font = [Uifont systemfontofsize: -]; [Self.view Addsubview:field];
xcode--Code creation button, text input box