Set the custom button
UIButton *button1=[uibutton Buttonwithtype:uibuttontypecustom];
Set a rounded button
UIButton *button1=[uibutton Buttonwithtype:uibuttontyperoundedrect];
Button1.frame=cgrectmake (80,250,250, 30);//position coordinates of the button
[Button1 settitle:@ "Button1" forstate:uicontrolstatenormal];//normal status button title
[Button1 settitle:@ "highlight status" forstate:uicontrolstatehighlighted];//highlighted button title
Highlight Status Glow Effect
[Button1 Setshowstouchwhenhighlighted:yes];
Set the color of a caption
[button1 Settitlecolor:[uicolor Redcolor] forstate:uicontrolstatenormal];
Set the font size for headings
[Button1.titlelabel Setfont:[uifont boldsystemfontofsize:20];
Set Background color
[button1 Setbackgroundcolor:[uicolor Bluecolor];
Picture is stretched to set background picture
[Button1 setbackgroundimage:[uiimage imagenamed:@ "1.jpg"] forstate:uicontrolstatenormal];
Picture keeps the original size set background picture
[Button1 setimage:[uiimage imagenamed:@ "1.jpg"] forstate:uicontrolstatenormal];
[[button1 Titlelabel]setshadowcolor:[uicolor Blackcolor]];
[[Button1 Titlelabel]setshadowoffset:cgsizemake (-0.5,-0.5)];
Button1.contenthorizontalalignment=uicontrolcontenthorizontalalignmentleft;
[Self.view Addsubview:button1];
Monitoring Events
[Button1 addtarget:self Action: @selector (Click_button) forcontrolevents:uicontroleventtouchupinside];
}
-(void) Click_button
{
NSLog (@ "clicked ...");
}
Not finished, to be continued to update ...
IOS UIButton various properties settings Daquan