按鈕中圖片和文字的左右位置

文字在右,圖片在左(默認狀態)

button.imageEdgeInsets =UIEdgeInsetsMake(0,0, 0, labelWidth);

button.titleEdgeInsets =UIEdgeInsetsMake(0,0, 0,0);


文字在左,圖片在右

button.imageEdgeInsets = UIEdgeInsetsMake(0,labelWidth0, -labelWidth);

button.titleEdgeInsets = UIEdgeInsetsMake(0,-imageWidth0imageWidth);



原因:
   buttonimageEdgeInsets和titleEdgeInsets屬性是相比於原來位置的偏移量,並不影響按鈕大小
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章