Shi*_*ney 4 xcode objective-c shadow uiimageview ios
我正在尝试为我的Imageview提供阴影效果,就像在此图像中一样.

但我面临的问题是阴影实际上是从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];
Run Code Online (Sandbox Code Playgroud)
请提供意见.如果方法有误,请随时引导我采用任何其他方法.提前致谢.
任何人都可以建议如何提供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;
Run Code Online (Sandbox Code Playgroud)
您需要使用这些值进行游戏以符合您的要求.希望这可以帮助.
这是我的输出:

| 归档时间: |
|
| 查看次数: |
7185 次 |
| 最近记录: |