Reputation: 22569
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:
is there anyway I can control this behavior to reach a consistent look on both versions?
Upvotes: 2
Views: 1721
Reputation: 2918
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.
Upvotes: 0
Reputation: 22569
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;
Upvotes: 4