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