阴影

self.layer.masksToBounds = NO;
self.layer.shadowColor = color.CGColor; // 阴影的颜色
self.layer.shadowOpacity = opacity; // 阴影透明度
self.layer.shadowOffset = CGSizeMake(0,0); // 阴影的范围
self.layer.shadowRadius = spread/2; // 阴影扩散的范围控制

float border=spread/2;
self.layer.shadowOpacity = opacity;
self.layer.masksToBounds = NO;
self.layer.shadowColor = color.CGColor;
self.layer.shadowRadius = border;
self.layer.shadowOffset = CGSizeMake(0,0);

float width = self.bounds.size.width;
float height = self.bounds.size.height;

UIBezierPath* aPath = [UIBezierPath bezierPathWithRect:CGRectMake(-border, -
border, width+border, height+border)];
aPath.lineWidth = border;
aPath.lineCapStyle = kCGLineCapRound;
aPath.lineJoinStyle = kCGLineCapRound;
self.layer.shadowPath = aPath.CGPath;

你可能感兴趣的:(阴影)