Вопрос

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