IPhone uibutton Development Summary

Source: Internet
Author: User

1. Create
+ Buttonwithtype: // create and return a button of a specific style

2. Set the title
Buttontype Property
Titlelabel property // view of the current title of the display button (read-only ). although it is read-only, its attributes are read/write. its properties return values before the buttons are displayed. the system button values are nil.
Reversestitleshadowwhenhighlighted property // determine whether to change the bool value of the shadow when the button is highlighted. the default value is no. When the value is yes, the shadow changes between the engraving and relief feeling (almost the opposite number of normal offset is used as the new offset)
-Settitle: forstate: // set the title of different states. The default title of different States is the value of uicontrolstatenormal. if the value of the normal status is not set, the default value is a system value, so you only need to set the normal status
-Settitlecolor: forstate: // set the title Color for different states. the default title Color of different States is the value of uicontrolstatenormal. if the value of the normal status is not set, the default value is a system value, so you only need to set the normal status
-Settitleshadowcolor: forstate: // sets the title shadow color for different states. the default title shadow color in different States is the value in uicontrolstatenormal. if the value of the normal status is not set, the default value is a system value, so you only need to set the normal status
-Titlecolorforstate: // Title color when different states are returned.
-Titleforstate: // The title when different states are returned.
-Titleshadowcolorforstate: // The title shadow color when different states are returned.
Font property deprecated in IOS 3.0
Linebreakmode property deprecated in IOS 3.0
Titleshadowoffset property deprecated in IOS 3.0

3. Set button images
Adjustsimagewhenhighlighted property // determines whether the bool value of the image is changed when the button is highlighted. If the bool value is true, the image is highlighted with the button.
Adjustsimagewhendisabled property // determines whether the bool value of the image is changed when the button is highlighted. If the bool value is true, the image is dimmed when the button fails.
Showstouchwhenhighlighted property // controls whether the bool value is flashing when the button is pressed. No by default. If yes, a white spot is clicked. The image and button events will not change due to the Flash.
-Backgroundimageforstate: // return the background image used in the status of a button.
-Imageforstate: // return the button image in a certain state.
-Setbackgroundimage: forstate: // sets the background image of a specific State. The default value is normal.
-Setimage: forstate: // sets the image in the specified state. The default value is normal.

4. Set the boundary distance
Contentedgeinsets property // button content inside and outside borders draw area. content contains button image and title
Use this property to resize and reposition the specified tive drawing rectangle for the button content. the content comprises the button image and button title. you can specify a different value for each of the four insets (top, left, bottom, right ). A positive
Value shrinks, or insets, that edge-moving it closer to the center of the button. A negative value expands, or outsets, that edge. use the uiedgeinsetsmake function to C ***** truct a value for this property. the default value is uiedgeinsetszero.

Titleedgeinsets property // Area Control for button title painting.
Use this property to resize and reposition the specified tive drawing rectangle for the button title. you can specify a different value for each of the four insets (top, left, bottom, right ). A positive value shrinks, or insets, that edge-moving it closer to
Center of the button. A negative value expands, or outsets, that edge. Use the uiedgeinsetsmake function to C ***** truct a value for this property. The default value is uiedgeinsetszero.
Imageedgeinsets property // controls the image painting offset area.
Use this property to resize and reposition the specified tive drawing rectangle for the button image. you can specify a different value for each of the four insets (top, left, bottom, right ). A positive value shrinks, or insets, that edge-moving it closer to
Center of the button. A negative value expands, or outsets, that edge. Use the uiedgeinsetsmake function to C ***** truct a value for this property. The default value is uiedgeinsetszero.

5. Get the current status
Currenttitle property // The title (read-only) displayed on the current button. The value is automatically changed when the button status changes. The value can be nil.
Currenttitlecolor property // the color of the current title (read-only). Make sure this value is not nil. The default value is white.
Currenttitleshadowcolor property // The title shadow color (read-only). The default value is white.
Currentimage property // The image on the current button (read-only). It can be nil.
Currentbackgroundimage property // The background image of the current button (read-only). It can be nil.
Imageview property // The Image view on the button (read-only ). although it is read-only, its attributes are read/write. the imageview attribute has a value before the button is displayed. the value of the system button is nil.

6. Obtain the dimension.
-Backgroundrectforbounds: // return to the background painting area.
-Contentrectforbounds: // the area where the returned content is drawn. The content area shows the image and title and their specific alignment and scaling ranges.
-Titlerectforcontentrect: // return the title area.
-Imagerectforcontentrect: // return the area of the image.

7. Others
Button type
Typedef Enum {
Uibuttontypecustom = 0, // No style
Uibuttontyperoundedrect, // corner style button
Uibuttontypedetaildisclosure ,//
Uibuttontypeinfolight, // click the bright background information button
Uibuttontypeinfodark, // The information button of the dark background
Uibuttontypecontactadd ,//
} Uibuttontype;

Button status:

Uicontroleventtouchdown // Press
Uicontroleventtouchdownrepeat // Press
Uicontroleventtouchdraginside // hold down and drag the button and its peripheral
Uicontroleventtouchdragoutside // hold down and drag outside the button
Uicontroleventtouchdragenter // trigger when dragoutside enters draginside
Uicontroleventtouchdragexit // triggered from in to out
Uicontroleventtouchupinside // release the button and its peripheral
Uicontroleventtouchupoutside // release the button outside
Uicontroleventtouchcancel // click Cancel

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.