iphone - 如何给 UINavigationController 添加阴影

标签 iphone objective-c ios6 uinavigationcontroller shadow

我想创建一个像 Path 或 Facebook 中的幻灯片菜单,在菜单和 UINavigationController 之间有一个阴影,其中包含所有内容。我可以向图层添加圆角,但应用到图层的阴影不会显示。该代码有什么问题?如果我使用 UIViewController 而不是 UINavigationController,它就可以工作...(代码位于作为 rootViewController 添加到 UINavigationController 的 View 内)

问题是我不想松开 UINavigationController 的圆形边框

self.navigationController.view.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:self.navigationController.view.bounds cornerRadius:self.navigationController.view.layer.cornerRadius].CGPath;
[self.navigationController.view.layer setMasksToBounds:YES];
[self.navigationController.view.layer setShadowColor:[UIColor blackColor].CGColor];
[self.navigationController.view.layer setShadowOffset:CGSizeMake(0, 0)];
[self.navigationController.view.layer setShadowOpacity:0.5];
[self.navigationController.view.layer setShadowRadius:3];
[self.navigationController.view.layer setCornerRadius:3];

最佳答案

问题是

[self.navigationController.view.layer setMasksToBounds:YES];

顾名思义,图层之外的所有内容(包括阴影)都被 mask 。

关于iphone - 如何给 UINavigationController 添加阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15043038/

相关文章:

iphone - 如何安全地存储在应用程序首选项中输入的凭据?

objective-c - 'garbage value' 'Left operand of ' 生成的/' is a garbage value' 警告中的 "Build & Analyze"是什么?

uiscrollview - 在 iOS 5 模拟器上运行时,使用 iOS 6.0 SDK 和构建 iOS 5 Target 会导致 UIScrollView setMinimumZoomScale 失败

ios - Swift 项目的代码签名问题

iphone - Bonjour 数据发送多个设备

ios - 使用 Storyboard 的条件转场

iphone - 将两个 CAF 文件混合在一起

ios - 了解 iOS 中的配置文件和证书

ios - 从弹出窗口打开全屏模式时,相机的屏幕位置不正确

iphone - 在 iOS 付费应用程序契约(Contract)生效之前,我可以在开发沙盒中使用 iOS 进行应用程序购买吗