UIButton implement left text right picture

Source: Internet
Author: User

Code implementation:

[Btnright settitleedgeinsets:uiedgeinsetsmake (0,-imgarrow.size.width, 0, ImgArrow.size.width)];
[Btnright setimageedgeinsets:uiedgeinsetsmake (0, BtnRight.titleLabel.bounds.size.width, 0,- BtnRight.titleLabel.bounds.size.width)];

UIButton default is left picture, right text. And the position has been set before the edge insets is set. So setting the title of The Edge insets, the real function is to increase or decrease a certain distance on the basis of the original margin value, the negative value is reduced. Take the title as an example, set the right margin to increase the width of the picture, so that the right edge of their own border distance button to the right of the width of the picture, just put the film. At this point, the title lable has become smaller, and the title lable the left edge of the original position, so the left edge of the lable to reduce the width of the left border of the picture, lable is as big as the original, and the left start position and the picture left the same position.

Xib implementation:

UIButton implement left text right picture

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.