UIButton vertical arrangement + two intervals

Source: Internet
Author: User

-(void) layoutsubviews {    [super layoutsubviews];    /*         super view frame     47:317 ---------------     | |      |      |23:46|imgView     |     | --------------    |     | |     |         |  |      | |  46        |  |     |--|--23  . Center |  |     *///    // center image     CGRect rect = self.imageView.frame;     rect.size.height=20;    rect.size.width=20;    //fixed layer height and width, avoid offset, see your project image size     self.imageView.frame = rect;     cgpoint center = self.imageview.center;    cgrect  newFrame = [self titleLabel].frame;    center.x =  self.frame.size.width/2;    center.y = self.frame.size.height/2 -  newframe.size.height/2;    self.imageview.center = center;         //Center text    newFrame.origin.x =  The left distance of the self.imageview.frame.size.width/2 + _spacing/2;    //↑ text box is the width of the   icon/2  +  interval distance/2, because the default layout picture is left, the text is in the right     newFrame.origin.y =  self.imageview.frame.size.height + self.imageview.frame.origin.y + _spacing;     //↑ the top distance of the text box is the y-coordinate of the   icon + the height of the picture itself + distance     newframe.size.width = self.frame.size.width;    self.titlelabel.frame  = newframe;}

Overriding the Layoutsubviews method in inheriting from the UIButton class


UIButton vertical arrangement + two intervals

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.