Question

I am using the UIPopoverBackgroundView class to display a custom UIPopover.

Here is the thing. On iOS 5, the popover is displayed without dropping any shadows behind the popover. However, in iOS 6, the popover drops a very strange shadow that does not perfectly fit the popover:

ios 5 popover

ios 6 popover

is there anyway I can control this behavior to reach a consistent look on both versions?

Was it helpful?

Solution

In order to remove the shadow on iOS 6, and add a custom shadow to your popover:

1) remove the shadow by overriding layoutSubviews

- (void)layoutSubviews {
    // remove shadow (iOS 6)
}

2) Add a shadow property to your BG view

_borderView.layer.shadowColor = [UIColor blackColor].CGColor;
_borderView.layer.shadowOpacity = 1.f;
_borderView.layer.shadowRadius = 15;
_borderView.layer.shadowOffset = CGSizeMake(0.0f, 0.0f);

_borderView.layer.shouldRasterize = YES;

OTHER TIPS

You can manually set the shadow offset on your UIPopoverBackgroundView layer:

self.layer.shadowOffset = CGSizeMake(_leftOffset, 0);

Edit: In other words, the shadow is right, just in the wrong place.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top