[IOS series]-unconventional use of UIButton

Source: Internet
Author: User

[IOS series]-unconventional use of UIButton
This article mainly introduces the tips of UIButton in development, which can achieve amazing results. 1: Set the button padding attribute to display the effect btn of the photo frame. contentEdgeInsets = UIEdgeInsetsMake (CGFloat top, CGFloat left, CGFloat bottom, CGFloat right); 2: UIButton displays images and text (for small icons ), because UIButton has a special structure (including UIImageView and UILabel), we can present it in the following way. // 1: the first method is btn. enabled = NO; btn. adjustsImageWhenDisabled; // 2: The second method is btn. adjustsImageWhenHighlighted; 3: retrieve the UIButton attributes. You can not only set the attributes: setTitle, setImage... similarly, we can retrieve the corresponding property value based on the button status: // obtain the text of the button-(NSString *) titleForState :( UIControlState) state; // obtain the text color of the button-(UIColor *) titleColorForState :( UIControlState) state; // obtain the button image-(UIImage *) imageForState :( UIControlState) state; // obtain the background image of the button-(UIImage *) backgroundImageForSta Te :( UIControlState) state; if this is inconvenient, we can use the 'currenttitle, currentTitleColor, currentImage, and currentBackgroundImage attributes of UIButton to obtain the current attribute value.

Related Article

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.