Button的標(biāo)題和圖片可以同時(shí)設(shè)置,誰(shuí)左誰(shuí)右捐腿,誰(shuí)上誰(shuí)下纵朋,我們自己說(shuō)了算,雖然默認(rèn)是圖片左標(biāo)題右茄袖。
CGSize titleSize = [AppUtil sizeWithText:@"標(biāo)題文字" maxSize:CGSizeMake(CGFLOAT_MAX, 20) font:SYSTEMFONT(16)];//自己計(jì)算文字的大小
CGSize imgSize = bb.size;//圖片大小
[otherItemBtn setImageEdgeInsets:UIEdgeInsetsMake(0, titleSize.width, 0, -titleSize.width)];
[otherItemBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -imgSize.width, 0, imgSize.width)];
如果只單獨(dú)設(shè)置了ImageEdgeInsets或者TitleEdgeInsets操软,那參數(shù)是參照button的;只有同時(shí)設(shè)置時(shí)才是image參照title宪祥,title參照image聂薪;最重要的還是需要區(qū)分UIEdgeInsetsMake參數(shù)的正負(fù),正負(fù)不同位移不同蝗羊。