iOS Settings button picture text up and down, left and right

Source: Internet
Author: User

[btn Setimage:imgnor forstate:uicontrolstatenormal];            [Btn Setimage:imgsel forstate:uicontrolstateselected];            [btn Settitle:[arrlabel objectatindex:i] forstate:uicontrolstatenormal];            [Btn Settitlecolor:kcolor_tabbarnor Forstate:uicontrolstatenormal];    [Btn Settitlecolor:kcolor_tabbarsel forstate:uicontrolstateselected]; //The settings control is arranged in the top left, otherwise the default is mediumBtn.contentverticalalignment =Uicontrolcontentverticalalignmenttop; Btn.contenthorizontalalignment=Uicontrolcontenthorizontalalignmentleft; Btn.titleLabel.font=Kfont (Ktext_size_mini);//(top, left, next bottom, right)//sets the offset of the title of the image + the height of the picture + (remaining space-text height)/2.  Bottom center Displays the text left offset: (width of the control-the width of the text)/2-the width of the picture. This is important, why subtract the width of the picture?? Because the default picture text arrangement is the picture on the left, the text follows the picture, i.e. the text is on the right side of the picture. This subtracts the width of the picture. Bt.titleedgeinsets = Uiedgeinsetsmake ((bt.imageedgeinsets.top+image_sel.size.height) + (bt.frame.size.height-( Bt.imageedgeinsets.top+image_sel.size.height)-size.height)/2, (Bt.frame.size.width-size.width)/2-image_sel.size.width,0,0); //set the offset of the picture: Left offset setting, width of control-width of picture)/2. Center Display picture[Btn Setimageedgeinsets:uiedgeinsetsmake (4, (Width-imgnor.size.width)/2,0,0)];

iOS Settings button picture text up and down, left and right

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.