self.bgView.layer.shadowOffset = CGSizeMake(1,1);
self.bgView.layer.shadowOpacity = 0.3;
self.bgView.layer.shadowColor = [UIColor lightGrayColor].CGColor;
添加阴影效果方法二
// 以下是添加的阴影效果
view.layer.shadowColor = color.CGColor;//shadowColor阴影颜色
view.layer.shadowOffset = CGSizeMake(0,1);//shadowOffset阴影偏移,x向右偏移4,y向下偏移4,默认(0, -3),这个跟shadowRadius配合使用
view.layer.shadowOpacity = 0.2;//阴影透明度,默认0
view.layer.shadowRadius = 2;//阴影半径,默认3
UIBezierPath * path = [UIBezierPath bezierPath];
float width = view.bounds.size.width;
float height = view.bounds.size.height;
float x = view.bounds.origin.x;
float y = view.bounds.origin.y;
float addWH = 2;
CGPoint topLeft = view.bounds.origin;
CGPoint topMiddle = CGPointMake(x+(width/2),y-addWH);
CGPoint topRight = CGPointMake(x+width,y);
CGPoint rightMiddle = CGPointMake(x+width+addWH,y+(height/2));
CGPoint bottomRight = CGPointMake(x+width,y+height);
CGPoint bottomMiddle = CGPointMake(x+(width/2),y+height+addWH);
CGPoint bottomLeft = CGPointMake(x,y+height);
CGPoint leftMiddle = CGPointMake(x-addWH,y+(height/2));
[path moveToPoint:topLeft];
[path addQuadCurveToPoint:topRight
controlPoint:topMiddle];
[path addQuadCurveToPoint:bottomRight
controlPoint:rightMiddle];
[path addQuadCurveToPoint:bottomLeft
controlPoint:bottomMiddle];
[path addQuadCurveToPoint:topLeft
controlPoint:leftMiddle];
view.layer.shadowPath = path.CGPath;
可以根据自己的需求来为view 添加阴影效果