iOS changes the button's image and title position according to Uiedgeinsets

Source: Internet
Author: User

Just found on the Web property Settings button content on the image under the title in UIButton there are three settings for Edgeinsets: Contentedgeinsets, titleedgeinsets, Imageedgeinsets@property (nonatomic) uiedgeinsets contentedgeinsets ui_appearance_selector;//default is Uiedgeinsetszero /c1>@property (nonatomic) uiedgeinsets titleedgeinsets; Default is Uiedgeinsetszero@property (nonatomic) BOOL reversestitleshadowwhenhighlighted;//default is NO. If YES, shadow reverses to shift between engrave and emboss appearance@property (nonatomic) uiedgeinsets imageedgeinsets; Default is Uiedgeinsetszero  typedef struct Uiedgeinsets {     cgfloat top, left, bottom, right;  //Specify amount to inset (positive) for each of the edges. Values can is negative to ' outset '  } The four parameters inside the uiuiedgeinsetsmake represent distances from the top, left, bottom, and right boundaries, which are zero by default. Title/image in the center of the button [OBJC]  uikit_static_inline uiedgeinsets uiedgeinsetsmake (cgfloat top, CGFloat left, CGFloat Bottom, cgfloat right) {     uiedgeinsets insets = {top, left, bottom, right};      return insets;  }       button.imageedgeinsets = Uiedgeinsetsmake (5,13,21, Button.titleLabel.bounds.size.width);//Set the position of the image on the button (top, left, bottom bottom, right) here can write negative values, write to 5, Then image is like moving up 5 pixels                button.titleedgeinsets = Uiedgeinsetsmake (-button.titlelabel.bounds.size.width-50, 0, 0);//Set the title position on the button (top, left, bottom bottom, right)                //  Button.contEnthorizontalalignment = uicontrolcontenthorizontalalignmentcenter;//The contents of the button are centered horizontally ... Set content is title and image change together                     & nbsp             

iOS changes the button's image and title position according to Uiedgeinsets

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.