Customize the layout of buttons with pictures and text

Source: Internet
Author: User

Customize button to load pictures and text dynamically

[Footview Addsubview:btnallchoose];    [Btnallchoose settitle:str Forstate:uicontrolstatenormal]; [Btnallchoose settitlecolor:[uicolor colorwithhexstring:@"#666666"] Forstate:uicontrolstatenormal]; BtnAllChoose.titleLabel.font= [Uifont systemfontofsize:Ten]; [Btnallchoose setimage:[uiimage imagenamed:@"List_selected_icon"] forstate:uicontrolstateselected]; [Btnallchoose setimage:[uiimage imagenamed:@"List_give_icon"] Forstate:uicontrolstatenormal];    [Btnallchoose addtarget:self Action: @selector (btnallchooseaction:) forcontrolevents:uicontroleventtouchupinside]; Btnallchoose.tag=1001;

Customize UIButton and Inherit UIButton, modify button, internal method

//frame of internal picture-(CGRect) Imagerectforcontentrect: (cgrect) contentrect{cgfloat Imagew=ContentRect.size.height; CGFloat Imageh=ContentRect.size.height;//DLOG (@ "imageh=%g", Imageh);    returnCGRectMake (0,0, Imagew, Imageh);}//frame with inner text-(CGRect) Titlerectforcontentrect: (cgrect) contentrect{cgfloat titlew= contentrect.size.width-contentrect.size.height-5; CGFloat Titleh=ContentRect.size.height; returnCGRectMake (titleh+5,0, Titlew, Titleh);}

Customize the layout of buttons with pictures and text

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.