UIButton left text right picture, on picture below text

Source: Internet
Author: User

One: The default is the left picture right text

Two: Left text right picture (direct copy code to project can)

    [Btn settitleedgeinsets:uiedgeinsetsmake (0,-btn.imageview.size.width, 0, Btn.imageView.size.width)];
    [Btn setimageedgeinsets:uiedgeinsetsmake (0, btn.titleLabel.bounds.size.width, 0,-btn.titlelabel.bounds.size.width )];

Three: The picture below the text (direct copy code to the project)

Btn.contenthorizontalalignment = uicontrolcontenthorizontalalignmentcenter;//to center the picture and text horizontally  
    [btn Settitleedgeinsets:uiedgeinsetsmake (Btn.imageView.frame.size.height,-btn.imageview.frame.size.width, 0.0,0.0)] ;//text distance from the top border to increase the height of imageview, distance from the left to reduce the width of the ImageView, the distance from the bottom and right border  
    [btn setimageedgeinsets:uiedgeinsetsmake (0.0, 0.0,0.0,-btn.titlelabel.bounds.size.width)];//picture distance from the right border to reduce the width of the picture, others  



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.