How to disable darker transparent effect in UIPopoverController in iOS7?

I am using the UIPopoverController for a popup on an iOS7 iPad as follows:

if (!self.popover) { UIViewController *popupVC = [[UIViewController alloc] init]; [popupVC.view addSubview:thePopupView]; popupVC.preferredContentSize = CGSizeMake(240, 140); self.popover = [[UIPopoverController alloc] initWithContentViewController:popupVC]; self.popover.delegate = self; } [self.popover presentPopoverFromBarButtonItem:barButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 

But when the popover is active, it makes the screen darker , while this effect does not affect other views in iOS6.

How to overcome this problem? Thanks!

+7
ios ios7 uipopovercontroller
source share
2 answers

If you mean the dimming view that is inserted under popover, there is only one workaround - use a custom popoverBackgroundViewClass .

It is difficult, but not as difficult as you think.

+4
source share

Another method is to move the popover view stack and manually remove the dimming view, as shown here in a subclass of UIPopoverController :

 @property (nonatomic, assign) BOOL showsDimmingView; .... - (void)presentPopoverFromBarButtonItem:(UIBarButtonItem *)item permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated { [super presentPopoverFromBarButtonItem:item permittedArrowDirections:arrowDirections animated:animated]; if (!_showsDimmingView) { [self removeDimmingView:[[UIApplication sharedApplication].keyWindow.subviews lastObject]]; } } - (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated { [super presentPopoverFromRect:rect inView:view permittedArrowDirections:arrowDirections animated:animated]; if (!_showsDimmingView) { [self removeDimmingView:[[UIApplication sharedApplication].keyWindow.subviews lastObject]]; } } - (void)removeDimmingView:(UIView *)subview { for (UIView *sv in subview.subviews) { if (sv.alpha == 0.15f && [sv isKindOfClass:NSClassFromString(@"_UIPopoverViewBackgroundComponentView")]) { sv.alpha = 0.f; } const CGFloat *components = CGColorGetComponents(sv.backgroundColor.CGColor); if (sv.backgroundColor && (components[1] == 0.15f || sv.alpha == 0.15f)) { [sv removeFromSuperview]; } [self removeDimmingView:sv]; } } 
+2
source share

All Articles