IOS UIButton various properties settings Daquan

Source: Internet
Author: User

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

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.