iOS button Common Properties

Source: Internet
Author: User

1.UIButton Status:
UIControlStateNormal//Normal status
uicontrolstatehighlighted//Highlight Status
uicontrolstatedisabled//Disable status
uicontrolstateselected//Check Status
Uicontrolstateapplication//
uicontrolstatereserved//Reserved status
2.Uibutton Type:
Uibuttontypecustom//Custom type
Uibuttontyperoundedrect//Fillet type
Uibuttontypedetaildisclosure//Detail Display button
Uibuttontypeinfolight//Light Background Info button
Uibuttontypeinfodark//Dark Background information button
Uibuttontypecontactadd//Add button
3.UIButton Common Properties

When you set text to a button, the Apple document describes that you cannot use a Label object to set the color or shadow color of the text, but instead you must use the

SetTitleColor:forState:and Settitleshadowcolor:forstate: These two methods can modify these values.

Set other properties in the button and so on ....

Sets the caption content of the corresponding state to default is nil. Title is assumed-be-line-(void) Settitle: (NSString *) title forstate: (uicontrolstate) state;  Sets the caption color for the corresponding status           -(void) Settitlecolor: (Uicolor *) color forstate: (uicontrolstate) state;   Sets the caption shadow color for the corresponding status            -(void) Settitleshadowcolor: (Uicolor *) color forstate: (uicontrolstate) state;          Picture of the button that sets the corresponding status-(void) SetImage: (UIImage *) image forstate: (uicontrolstate) state;        

Add Event

-(void) AddTarget: (ID) Target action: (SEL) Action forcontrolevents: (uicontrolevents) controlevents;

These events are touch-based, value-based, and edit-based. The following events are triggered.

When the button is clicked, the button is concave, then the event is triggered, and the state of the button is:

    Uicontroleventtouchdown      //Press        uicontroleventtouchdownrepeat  multiple times Press       uicontroleventtouchupinside// Loosen the      uicontroleventtouchupoutside//button outside the button and its certain periphery  
4.adjustsImageWhenDisabled

When the button is disabled, the color of the image is drawn darker and the default is yes.

5.adjustsImageWhenHighlighted

When the button is highlighted, the color of the image is drawn darker and the default is yes.

6.showsTouchWhenHighlighted

Button.showstouchwhenhighlighted=yes; When clicked, the flash effect is obscured by the foreground image.

6.contentEdgeInsets

Sets the internal content of the button, including the button picture and caption, from the top or bottom of the button edge.

7. Button instance

1. Sometimes we want the title of UIButton to be left aligned, we set
Btn.textlabel.textalignment= Uitextalignmentleft

is not useful, we need to set

Btn.contenthorizontalalignment = Uicontrolcontenthorizonalignmentleft;

But the problem comes out again, when the text is pressed to the left border, we can set

Btn.contentedgeinsets = Uiedgeinsetsmake (0,10, 0, 0);

Keeps the text distance from the left border by 10 pixels.

iOS button Common Properties

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.