The login button//. h defines UIButton *_loginbtn; @property (strong,nonatomic) UIButton *loginbtn; The Implement Settings button in. m @synthesize loginbtn = _loginbtn;//Use the backup variable name//Set button shape self.loginbtn = [UIButton buttonwithtype : Uibuttontyperoundedrect]; /* Buttonwithtype: Defines the shape of button buttons six defines the button type: There is a plot uibuttontypecustom = 0, no type Uibuttontyperoundedre CT, four angles are arc-shaped uibuttontypedetaildisclosure, Uibuttontypeinfolight, Uibuttontypeinfodark, Uibuttontype Contactadd, *///define the coordinates (position) of button buttons on the frame, and the width/height of this button Self.loginBtn.frame = CGRectMake (40, 200, 80, 30); [Self.loginbtn settitle:@ "Login" forstate:uicontrolstatenormal]; /* Common Properties: Settitle: Set the button name setimage: [UIImage imagenamed:@ "picture name"] Add picture Settitlecolor:[uicolor re Dcolor] Set the font Color Forstate Settings button before and after the state: there is an illustration uicontrolstatehighlighted uicontrolstateselected Uicon Trolstatedisabled UIControlStateNormal //////Add an action//action for the button: The method executed if clicked [Self.loginbtn addtarget:self Action: @selector (Login:) Forcontrol Events:uicontroleventtouchupinside]; Add a button control to the view to display [Self.view ADDSUBVIEW:SELF.LOGINBTN];
How to perform the action-(ibaction) Login: (ID) sender;
Six definitions of button types:
Uibuttontypecustom = 0, no type
Uibuttontyperoundedrect, Four corners are arc shaped
Uibuttontypedetaildisclosure
Uibuttontypeinfolight
Uibuttontypeinfodark
Uibuttontypecontactadd
Forstate setting the state of the button before and after clicking
Click before you click
uicontrolstatehighlighted
uicontrolstateselected
Uicontrolstatedisabled
UIControlStateNormal
Uibuttontyperoundedrect is set to this property, is to meet our normal situation of the button fillet, when we add a background image and background color on the button, we will find that this property does not apply, because the button is now not rounded corners, It shows the shape of the picture, and it can be displayed when the setting background color is set to the Uibuttontypecustom property. So we need to use the other properties of the UIButton control to meet our needs.
UIButton *btn; [Btn.layer Setmaskstobounds:yes]; [Btn.layer setcornerradius:10.0];//Set Rectangle four fillet radius/ * [btn.layer setborderwidth:1.0];//Border Width */
Original: http://blog.csdn.net/like7xiaoben/article/details/7588551
Go-uibutton define and set rounded corners