我试图为我的 Imageview 提供阴影效果,就像这张图片中一样。
![enter image description here](https://i.stack.imgur.com/RIVQW.jpg)
但我面临的问题是阴影实际上从 Imageview 的底部可见。
这是我添加阴影的代码。颜色什么的还是和这个不匹配。
CAGradientLayer *shadow = [CAGradientLayer layer];
shadow.frame = CGRectMake(-100, 70, perspectiveView.frame.size.width,
perspectiveView.frame.size.height - 20);
shadow.startPoint = CGPointMake(1.0, 0.5);
shadow.endPoint = CGPointMake(0, 0.5);
shadow.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithWhite:0.0
alpha:0.4f] CGColor], (id)[[UIColor clearColor] CGColor], nil];
shadow.opacity = 1.0f;
[perspectiveView.layer addSublayer:shadow];
请提供意见。另外,如果方法错误,请随时指导我采取其他方法。
提前致谢。
另外,任何人都可以建议如何提供 3D 边框,就像图像中一样,为图像视图提供轻微的宽度?
也许,向图层添加阴影似乎可行。您可能想尝试这样的事情:
// perspectiveView.transform = CGAffineTransformMakeRotation(-50.0f);
perspectiveView.layer.shadowOffset = CGSizeMake(10, 10);
perspectiveView.layer.shadowRadius = 5.0;
perspectiveView.layer.shadowOpacity = 0.6;
perspectiveView.layer.masksToBounds = NO;
您将需要尝试使用这些值来满足您的要求。希望这可以帮助。
这是我的输出:
![enter image description here](https://i.stack.imgur.com/ThiAV.png)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)