//创建Button
UIButton *button =[ [UIButton alloc]init;
//设置button的坐标和尺寸
button.frame = CGRectMake(100,100,100,100);
//设置文字
[button setTitle:@"输入你想要的文字" forState:UIControlStateNormal];
/*前三个较为常用
UIControlStateNormal //正常状态下
UIControlStateHighlighted //高亮状态下,按钮按下还未抬起的时候
UIControlStateDisabled //按钮禁用状态下,不能使用
UIControlStateSelected //选中状态下
UIControlStateApplication //当应用程序标志时
UIControlStateReserved //为内部框架预留
*/
//设置文字字体
button.titleLabel.font = [UIFont systemFontOfSize:14.0];
//设置文字颜色
[button setTitleColor:[UIColor BlackColor] forState:UIControlStateNormal];
//设置文字左对齐
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
//设置文字居中
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter