
图片阴影
Code
imageView.layer.shadowColor = [UIColor greenColor].CGColor;//阴影颜色 imageView.layer.shadowOffset = CGSizeMake(0, 0);//偏移距离 imageView.layer.shadowOpacity = 0.5;//不透明度 imageView.layer.shadowRadius = 10.0;//半径
圆形图片设置阴影(补充)
//超过子图层的部分裁减掉,所以给圆角的图片设置阴影会被裁掉 view.layer.masksToBounds=YES
设置图片圆角阴影
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. self.view.backgroundColor = [UIColor whiteColor]; UIView *view2 = [[UIView alloc] init]; view2.backgroundColor = [UIColor clearColor]; view2.frame = CGRectMake(90, 150, 200, 200); view2.layer.shadowOpacity = 0.8; view2.layer.shadowOffset = CGSizeMake(0, 3); view2.layer.shadowRadius = 10; UIView *view1 = [[UIView alloc] init]; view1.frame = CGRectMake(0, 0, 200, 200); view1.layer.masksToBounds = YES; view1.layer.cornerRadius = view1.frame.size.width/2; view1.backgroundColor = [UIColor yellowColor]; view1.layer.contents = (id)[UIImage imageNamed:@"wenli.png"].CGImage;; [self.view addSubview:view2]; [view2 addSubview:view1]; }
作者:骑行怪状
链接:https://www.jianshu.com/p/996601d17b5e
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。