UIview添加阴影效果Shadow

  UIview添加阴影效果Shadow

-(void)addGrayGradientShadow:(UIView*)view

{

view.layer.shadowOpacity = 0.5;

    

CGFloat bottomWidth = view.frame.size.width;

CGFloat bottomHeight = 1;

CGMutablePathRef shadowPath1 = CGPathCreateMutable();

CGPathMoveToPoint(shadowPath1, NULL, 0.0, 0.0);

CGPathAddRect(shadowPath1, NULL, CGRectMake(0,view.frame.size.height, bottomWidth, bottomHeight));

        CGPathAddRect(shadowPath1, NULL, CGRectMake(0,0, 0.4, view.frame.size.height));

        CGPathAddRect(shadowPath1, NULL, CGRectMake(view.frame.size.width-0.4,0,0.4,view.frame.size.height));

view.layer.shadowPath = shadowPath1;

CGPathRelease(shadowPath1);

    

view.layer.shadowOffset = CGSizeMake(0, 0);

view.layer.shadowRadius = 1.0;

    

}

这里为view的左下右添加阴影效果

你可能感兴趣的:(ios开发)