iOS UIButton添加圆角,添加边框

时间:2024-07-25 13:34:44
//准备工作
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(,,,);
button.backgroundColor = [UIColor blueColor];
//关键语句
button.layer.cornerRadius = 2.0;//2.0是圆角的弧度,根据需求自己更改
button.layer.borderColor = [UIColor blackColor];//设置边框颜色
button.layer.borderWidth = 1.0f;//设置边框颜色