Following is a snapshot of my popover:

enter image description here

I have an UIViewController (say A) that I want to show as popoverController. Also I want to customize popover so I am customizing the UIPopoverBackgroundView (say 'b' - orange background). Everything is working right except that after rounding the corners of A.view and 'b' I have a rectangular shadow line (which from the snapshot probably belongs to A.view - green background). Based on UIView or UIViewController APIs, is there any way I can remove that shadow. I am only interested in removing the black line on left, top and right of the view not the fuzzy looking shadow.

I did try:

[A.view.layer setShadowOpacity:0.0];

but no luck.

有帮助吗?

解决方案

In your UIPopoverBackgroundView subclass, override the class method:

+ (BOOL)wantsDefaultContentAppearance

To return NO. This prevents the drawing of the inner shadow as documented here.

其他提示

Remove the call for [super layoutSubviews] in your layoutSubviews method.

Overriding wantsDefaultContentAppearance and returning NO did not work for me.

You cannot control the shadow of a UIPopoverController directly. Your options are:

  1. Roll your own kind of popover.
  2. Subclass UIPopoverBackgroundView and provide your own graphics for the frame of the popover. Contrary to the official documentation, the shadow doesn't get drawn on for you when you subclass UIPopoverBackgroundView. Here's a great post on how to do this: http://blog.andrewkolesnikov.com/custom-background-color-tint-for-uipopover-64835
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top