我們是工程師 ——加油 走净!
按鈕UIButton 上的image,title等content右對(duì)齊
- 使用方法
setContentHorizontalAlignment
[self.attentionBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
- 下面三個(gè)方法無(wú)效,不要用
self.attentionBtn.contentMode = UIViewContentModeRight;
self.attentionBtn.contentMode = UIViewContentModeTopRight;
self.attentionBtn.contentMode = UIViewContentModeBottomRight;
- 同樣使用方法
setContentVerticalAlignment
實(shí)現(xiàn)上下對(duì)齊
枚舉值:
typedef NS_ENUM(NSInteger, UIControlContentHorizontalAlignment) {
UIControlContentHorizontalAlignmentCenter = 0,
UIControlContentHorizontalAlignmentLeft = 1,
UIControlContentHorizontalAlignmentRight = 2,
UIControlContentHorizontalAlignmentFill = 3,
UIControlContentHorizontalAlignmentLeading API_AVAILABLE(ios(11.0), tvos(11.0)) = 4,
UIControlContentHorizontalAlignmentTrailing API_AVAILABLE(ios(11.0), tvos(11.0)) = 5,
};