为UIView及其子类添加圆角边框

1.添加QuartzCore.framework

2.实现代码

 

UIView *bfPanel = [[UIView alloc]initWithFrame:CGRectMake(x, y, width, height)];
bfPanel.layer.masksToBounds = YES;
bfPanel.layer.borderWidth  =1;
bfPanel.layer.cornerRadius = 10;
bfPanel.layer.borderColor= [[UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:1] CGColor];
[mainView addSubview:bfPanel];
y +=height+10;
 

 

你可能感兴趣的:(UIView)