UIButton *uibuton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
//设置字体大小
uibuton.titleLabel.font=[UIFont boldSystemFontOfSize:12];
//设置uibuton 里面内容
[uibuton setTitle:@"haoyangdehaoyangdehaoyangdehaoyangdehaoyangdehaoyangdehaoyangde " forState:UIControlStateNormal];
//设置点击后的背景颜色
[uibuton setTintColor:[UIColor redColor]];
//设置文本内容颜色
[uibuton setTitleColor:[UIColor greenColor] forState:UIControlContentHorizontalAlignmentCenter];
//设置大小 位置
uibuton.frame=CGRectMake(150, 50, 170, 260);
//设置uibuton 图片
UIImage *image=[UIImage imageNamed:@"stop2.png"];
[uibuton setBackgroundImage:image forState:UIControlStateNormal];
//设置文本是否换行
uibuton.titleLabel.lineBreakMode=UILineBreakModeCharacterWrap;
//加载到视图里面
UIEdgeInsets insets;
insets.top=insets.bottom=insets.left=insets.right=10;
uibuton.contentEdgeInsets=insets;
[self.view addSubview:uibuton];
转载于:https://my.oschina.net/u/723252/blog/101759