NSTextField样式
NSTextAlignmentLeft = 0, // Visually left aligned
NSTextAlignmentCenter = 1, // Visually centered
NSTextAlignmentRight = 2,
accessoryType
typedef NS_ENUM(NSInteger, UITableViewCellAccessoryType) {
UITableViewCellAccessoryNone,
UITableViewCellAccessoryDisclosureIndicator,
UITableViewCellAccessoryDetailDisclosureButton __TVOS_PROHIBITED,
UITableViewCellAccessoryCheckmark,
UITableViewCellAccessoryDetailButton NS_ENUM_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED // info button. tracks
};
UIbutton 内容居左
有些时候我们想让UIButton的title居左对齐,我们设置
btn.textLabel.textAlignment = UITextAlignmentLeft
是没有作用的,我们需要设置
btn.contentHorizontalAlignment = UIControlContentHorizonAlignmentLeft;
UIControlContentHorizontalAlignmentLeft
但是问题又出来,此时文字会紧贴到做边框,我们可以设置
btn.contentEdgeInsets = UIEdgeInsetsMake(0,10, 0, 0);
使文字距离做边框保持10个像素的距离。
理解iOS按钮的文本对齐方式
本文详细解释了如何在iOS中通过设置不同属性来调整UIButton的文本对齐方式,包括使用UIControlContentHorizonAlignmentLeft和contentEdgeInsets来实现文字居左对齐并保持与边框的距离。
1万+

被折叠的 条评论
为什么被折叠?



