标签:图片圆角设置
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
view.backgroundColor = [UIColor redColor];
// 设置圆角
view.layer.cornerRadius = 10;
view.layer.masksToBounds = YES;
// .设置边框
view.layer.borderWidth = 5;
view.layer.borderColor = [UIColor greenColor].CGColor;
// 设置阴影的颜色
view.layer.shadowColor = [UIColor darkGrayColor].CGColor;
//设置阴影大小
view.layer.shadowOffset = CGSizeMake(50, 20);
//设置阴影的透明度
view.layer.shadowOpacity = 1;
// 设置阴影的路径
view.layer.shadowPath = [UIBezierPath bezierPathWithRect:CGRectMake(50, 20, 200, 200)].CGPath;
// 设置图片
view.layer.contents = (__bridge id)([UIImage imageNamed:@"image"].CGImage);
[self.view addSubview:view];
//本身也可以添加图片,不常用
CALayer *layer = [[CALayer alloc] init];
layer.frame = CGRectMake(10, 100, 300, 300);
layer.backgroundColor = [UIColor redColor].CGColor;
[self.view.layer addSublayer:layer];
CALayer *subLayer = [[CALayer alloc] init];
subLayer.frame = CGRectMake(10, 10, 100, 100);
subLayer.backgroundColor = [UIColor greenColor].CGColor;
[layer addSublayer:subLayer];
标签:图片圆角设置
原文地址:http://10554237.blog.51cto.com/10544237/1695298