UI基础之UIButton相关

时间:2023-03-09 01:17:03
UI基础之UIButton相关
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];

1、按钮透明效果

btn.alpha = 0.8;

2、按钮圆角处理

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

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

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

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

btn.imageEdgeInsets = UIEdgeInsetsMake(, , , -);
btn.titleEdgeInsets = UIEdgeInsetsMake(, -, , );

5、按钮点击

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