- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//创建UIButton
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button1.frame = CGRectMake(10, 30, 300, 30);
[button1 setTitle:@"圆角按钮" forState:UIControlStateNormal];
// 这句无效
// button1.titleLabel.textAlignment = NSTextAlignmentLeft;
button1.titleLabel.backgroundColor = [UIColor grayColor];
button1.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
button1.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
[button1.layer setBorderColor:[UIColor grayColor].CGColor];
[button1.layer setBorderWidth:1];
[button1.layer setCornerRadius:5.0f];
[button1.layer setMasksToBounds:YES];
[self.view addSubview:button1];
}