UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 200)];
view.backgroundColor = [UIColor grayColor];
//取出view的层
CALayer *layer = [view layer];
//设置层的弧度是10
layer.cornerRadius = 10;
//剪切掉多余的阴影
layer.masksToBounds = YES;
//设置层的边框的宽度为3
layer.borderWidth = 3;
//设置层的边框的颜色为红色,颜色转换成CGColor
layer.borderColor = [[UIColor redColor] CGColor];
[self.view addSubview:view];
网友评论