我们是工程师 ——加油 !
按钮UIButton 上的image,title等content右对齐
- 使用方法
setContentHorizontalAlignment
[self.attentionBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
self.attentionBtn.contentMode = UIViewContentModeRight;
self.attentionBtn.contentMode = UIViewContentModeTopRight;
self.attentionBtn.contentMode = UIViewContentModeBottomRight;
- 同样使用方法
setContentVerticalAlignment
实现上下对齐
枚举值:
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,
};
网友评论