Go-uibutton define and set rounded corners

Source: Internet
Author: User

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

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.