第一种方式:
CGPoint position= CGPointMake(_blueView.center.x, _blueView.center.y);//阴影中心点
CGFloat borderWidth = 2;
//阴影图层
CALayer *layerShadow=[[CALayer alloc]init];
layerShadow.bounds = _blueView.bounds;
layerShadow.position = position;
layerShadow.shadowColor = [UIColor grayColor].CGColor;
layerShadow.shadowOffset = CGSizeMake(2, 1);
layerShadow.shadowOpacity = 1;
layerShadow.borderColor = [UIColor whiteColor].CGColor;
layerShadow.borderWidth = borderWidth;
[self.view.layer addSublayer:layerShadow];
第二种方式:
_baseView.layer.cornerRadius = _baseView.bounds.size.height / 2;//设置阴影圆角
_baseView.layer.shadowOpacity = 0.5;//阴影透明度
_baseView.layer.shadowOffset = CGSizeMake(0, 0);//阴影偏移量
_baseView.layer.shadowRadius = 8;//阴影的半径