文字在右,圖片在左(默認狀態)
button.imageEdgeInsets =UIEdgeInsetsMake(0,0, 0, labelWidth);
button.titleEdgeInsets =UIEdgeInsetsMake(0,0, 0,0);
文字在左,圖片在右
button.imageEdgeInsets = UIEdgeInsetsMake(0,labelWidth, 0, -labelWidth);
button.titleEdgeInsets = UIEdgeInsetsMake(0,-imageWidth, 0, imageWidth);
原因:
button的imageEdgeInsets和titleEdgeInsets屬性是相比於原來位置的偏移量,並不影響按鈕大小