向 MKMapView 添加阴影
我有一个 MapView,我想添加它一个投影,但我尝试的方法不起作用:
- (void)viewDidLoad {
[super viewDidLoad];
mapView.layer.shadowColor = [[UIColor blackColor] CGColor];
mapView.layer.shadowOffset = CGSizeMake(10.0f, 10.0f);
mapView.layer.shadowOpacity = 1.0f;
mapView.layer.shadowRadius = 10.0f;
}
我得到这个:
我做错了什么吗?
I've a MapView, and I want to add it a dropshadow, but the method I tried doesn't work:
- (void)viewDidLoad {
[super viewDidLoad];
mapView.layer.shadowColor = [[UIColor blackColor] CGColor];
mapView.layer.shadowOffset = CGSizeMake(10.0f, 10.0f);
mapView.layer.shadowOpacity = 1.0f;
mapView.layer.shadowRadius = 10.0f;
}
I get this:
Am I doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决感谢:http://blog.amarkulo.com/create-rounded-uiviews -with-shadow
使用此代码:
Resolved thanks to: http://blog.amarkulo.com/create-rounded-uiviews-with-shadow
using this code:
另一种替代方案(实际上建议的解决方案对我不起作用,iOS SDK 4.3)是将 MKMapView 包含在 UIView 中:
这样您还可以对 _mapContainer 的框架进行动画处理,并仍然将阴影保持在正确的位置。
如果您是注册的 Apple 开发者,您可以在此处查看实际结果。
Another alternative (actually the proposed solution didn't work for me, iOS SDK 4.3) is to enclose the MKMapView in a UIView:
This way you can also animate the frame of the _mapContainer and still keep the shadow in its correct place.
Here you can see actual results here, if you're a registered Apple developer.