首页 > 代码库 > UI基础之UIButton相关

UI基础之UIButton相关

UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];

1、按钮透明效果

btn.alpha = 0.8;

2、按钮圆角处理

btn.layer.cornerRadius = 5;
btn.layer.masksToBounds = YES;

3、按钮文字字体大小(加粗)

btn.titleLabel.font = [UIFont boldSystemFontOfSize:13.0];

4、按钮文字、图片位置交换

btn.imageEdgeInsets = UIEdgeInsetsMake(0, 42, 0, -42);
btn.titleEdgeInsets = UIEdgeInsetsMake(0, -8, 0, 8);

5、按钮点击

[btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];

 

UI基础之UIButton相关