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;
}
本文介绍了一种在iOS开发中为UIView添加阴影效果的方法。通过调整阴影不透明度、路径、偏移和半径等属性,可以实现针对视图左下右三边的阴影效果。
2万+

被折叠的 条评论
为什么被折叠?



