首页 > 代码库 > UIButton文字左对齐以及增加边框

UIButton文字左对齐以及增加边框

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];

[button setFrame:CGRectMake(btnX, btnY, btnWidth, btnHeight)];

button.layer.borderWidth = 1;     // 边框宽度设置为1

[button setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];  // 左对齐

UIButton文字左对齐以及增加边框