如何消除“模糊” UIPopoverController 中的阴影
当 UIPopoverController 的视图出现时,我不想要阴影。有没有办法消除这种投影效果?
I don't want the drop shadow when the UIPopoverController's view appears. Is there a way to remove this drop shadow look?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不是很简单,但从 iOS 5 开始,您可以使用 UIPopoverBackgroundView 制作自己的自定义弹出框背景。
请参阅此问题的答案:使用 UIPopoverBackgroundView 类。它指向一个好的教程。
然后,在 UIPopoverBackgroundView 实现的 initWithFrame 中,您可以使用 clearColor 作为阴影。使用偏移和半径对我来说不起作用。
Not straight forward, but since iOS 5, you can make your own custom popover background using UIPopoverBackgroundView.
See the answer for this question: Using UIPopoverBackgroundView class. It's pointing to a good tuto.
Then, in the initWithFrame of your UIPopoverBackgroundView implementation, you can use a clearColor for the drop shadow. Using offset and radius did not work for me.
阴影是弹出视图图层的一个属性。如果您可以访问该图层,则可以将其阴影半径设置为 0.0,将阴影偏移设置为 {0.0, 0.0}。但是,看起来该视图必须是弹出窗口控制器的私有 ivar,因此没有一种简单的方法可以访问它。此外,如果您希望通过应用程序商店分发此应用程序,那么使用私有 ivar 并更改标准 UI 元素的外观都可能导致您的应用程序被拒绝。
The shadow is an attribute of the popover view's layer. If you could get access to the layer, you could set it's shadow radius to 0.0 and shadow offset to {0.0, 0.0}. However, it looks like the view must be a private ivar of the popover controller, so there's not an easy way to get to it. Moreover, if you're looking to distribute this app through the app store, using a private ivar and changing the look of standard UI elements both are likely to get your app rejected.
您只需使用自定义的 UIPopoverBackgroundView 并实现此功能:
You just have to use your custom UIPopoverBackgroundView and there implement this function: