Step-by-step learning iOS (UIbutton) detailed use

Source: Internet
Author: User

Uikit-button

A button that creates a rectangular rounded border, where you can place a picture, or you can place text

UIButton *button1 =[uibutton Buttonwithtype:uibuttontyperoundedrect];

Button1.frame = CGRectMake (100.0, 200.0, 50.0, 20.0);

Set the name of the Button1

[Button1 settitle:@ "one" forstate:uicontrolstatenormal];

Set the color of text

[button1 Settitlecolor:[uicolor Redcolor] forstate:uicontrolstatenormal];

Button background color

Button1.backgroundcolor = [Uicolor Orangecolor];

Set the label for Button1, commonly used in the delegate method, to identify the click is the button

Button1.tag = 0;

Formatting the button title

[Button1.titlelabel Setfont:[uifont boldsystemfontofsize:20];

Set the shadow of a button

[button1 Settitlecolor:[uicolor Redcolor] forstate:uicontrolstatenormal];

Add a background image to a button

[Button1 setimage:[uiimage imagenamed:@ "mtxx4"] forstate:uicontrolstatehighlighted];

By default, when the button is disabled, the image is drawn deeper, disabling this feature, setting the property to No

button1.adjustsimagewhenhighlighted = NO;

By default, when the button is disabled, the image is drawn lighter, disables this feature, and the property is set to No

button1.adjustsimagewhendisabled = NO;

property is set to Yes to enable the button to be illuminated when pressed

button1.showstouchwhenhighlighted = YES;

[Button1 addtarget:self Action: @selector (Btnshijian:) forcontrolevents:uicontroleventtouchupinside];//Add action

Step-by-step learning iOS (UIbutton) detailed use

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.