UIButton* button=[UIButton buttonWithType:UIButtonTypeCustom];
button.frame=CGRectMake(5, 8, 50, 29);
[button setBackgroundColor:[UIColor clearColor]];
[button setBackgroundImage:[UIImage imageNamed:@"button_back.png"] forState:UIControlStateNormal];
[button setBackgroundImage:[UIImage imageNamed:@"button_back_2.png"] forState:UIControlStateHighlighted];
[button setTitle:@"返回" forState:UIControlStateNormal];
button.titleEdgeInsets =UIEdgeInsetsMake(1, 5, 0, 0); // 4个参数分别是距离上,左,下,右的数据
button.titleLabel.font=[UIFont fontWithName:@"Helvetica-Bold" size:14];
本文介绍如何使用UIButton创建一个自定义样式的按钮,包括设置背景图片、标题及字体等属性。
4422

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



