iOS Summary _ implementation of the UIButton of the Graphic Mix (ii)

Source: Internet
Author: User

haven't written a blog for a long time, before written an article about the UIButton picture mixed, but a bit complicated, today to a relatively simple, I believe that everyone back to need


UIButton *button=[[UIButtonalloc] initwithframe:cgrectmake(60 , (+), (+)];

//Add text

[Button settitle:@ "Descriptive text" forstate:uicontrolstatenormal];

[Button settitlecolor: [uicolorredcolor] forstate: UIControlStateNormal];

//Plus picture

[Button setimage: [UIImageimagenamed:@ "pulldown"] Forstate:uicontrolstatenormal];

//plus border

button. Layer. BorderColor=[uicolorredcolor]. Cgcolor;

button. Layer. BorderWidth=0.5;


This is the effect of the mixing without changing the position, we will definitely change the position according to the different needs of everyone.

//change the graphic position around side

< Span style= "COLOR: #000000" >    button. Titleedgeinsets= uiedgeinsetsmake ( 0 Imageview Frame Size Width 0 Imageview Frame Size Width

button. Imageedgeinsets=uiedgeinsetsmake(0, button. Titlelabel. Frame. Size. Width+5,0, 0);


Description:The position of the edgeinsets is relative change, the specific people can be more code to understand


[Self. View addsubview: button];


iOS Summary _ implementation of the UIButton of the Graphic Mix (ii)

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.