
圖片陰影
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
來源:簡書
簡書著作權歸作者所有,任何形式的轉載都請聯系作者獲得授權並注明出處。