[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