iOS in a development series-UIButton Usage Summary

Source: Internet
Author: User

Initialize the button and set the type UIButton *btn = [UIButton buttonwithtype:uibuttontyperoundedrect];//can be defined by the following 6 types of UIButton://typedef enum {//Uibuttontypecustom = 0, self-defined style//uibuttontyperoundedrect, Rounded rectangle//Uibuttonty             Pedetaildisclosure, Blue small arrow button, mainly to do specific instructions with//uibuttontypeinfolight, bright exclamation mark//Uibuttontypeinfodark, Dark exclamation point//Uibuttontypecontactadd, Cross plus button//} uibuttontype;//set button size and position btn.frame = CGR Ectmake (20, 360, 280, 45);//Set button background color Btn.backgroundcolor = [Uicolor colorwithred:254/255.0f green:254/255.0f Blue : 254/255.0f alpha:1.0f];//Set button text [btn settitle:@ "Normal" forstate:uicontrolstatenormal]; [Btn settitle:@ "Pressed" forstate:uicontrolstatehighlighted];//forstate the role of this parameter is to define the state of the button's text or picture to appear, following several states:       enum {//UIControlStateNormal = 0, General status Show//uicontrolstatehighlighted = 1 << 0,     Highlight status Show//uicontrolstatedisabled = 1 << 1, The disabled state will only show//uicontrolstateselected = 1 << 2, check status//Uicontrolstateapplication = 0x00ff0000, When the application flags//uicontrolstatereserved = 0xff000000 is reserved for the internal frame, you can set the button text color regardless of his//};//[BTN Settitlecolor:[uico Lor Redcolor] forstate:uicontrolstatenormal];//set button text font [Btn.titlelabel Setfont:[uifont systemfontofsize:17]; [Btn.layer setmaskstobounds:yes];//Set button four fillet radius [btn.layer setcornerradius:4.0];//Set button border Width [btn.layer setborderwidth:0.5];//Set button border color cgcolorref colorref = Cgcolorcreate (Cgcolorspacecreatedevicergb (), (CGFloat[]) { 168/255.0f, 168/255.0f, 168/255.0f, 1.0}); [Btn.layer setbordercolor:colorref];//Remove button pressed delay in overlay view tableview.delayscontenttouches = no;//Join Click event [BTN Addtarget:self Action: @selector (btnaction:) forcontrolevents:uicontroleventtouchupinside];//display in view button[ TableView addsubview:btn];//button click Event-(void) Btnaction: (ID) sender{//Do something}

This article fixed link: http://www.itechzero.com/ios-development-series-one-uibutton-usage-summary.html. Reprint please indicate the source.

Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.

iOS in a development series-UIButton Usage Summary

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.