如下圖,想要達(dá)到這個效果,可以直接加兩行代碼。

image.png
//使圖片在右邊,文字在左邊(正常情況下是文字在右邊,圖片在左邊)
[_statusBtn setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];
//設(shè)置圖片和文字之間的間隙
_statusBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
如下圖,想要達(dá)到這個效果,可以直接加兩行代碼。
//使圖片在右邊,文字在左邊(正常情況下是文字在右邊,圖片在左邊)
[_statusBtn setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];
//設(shè)置圖片和文字之間的間隙
_statusBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);