Skip to content

Commit b2ce089

Browse files
committed
Ability to change overlay background color via UIAppearance
1 parent 2e56626 commit b2ce089

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

WYPopoverController/WYPopoverController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ typedef NS_OPTIONS(NSUInteger, WYPopoverArrowDirection) {
7575

7676
@property (nonatomic, assign) UIEdgeInsets viewContentInsets UI_APPEARANCE_SELECTOR;
7777

78+
@property (nonatomic, strong) UIColor *overlayColor UI_APPEARANCE_SELECTOR;
79+
7880
@end
7981

8082
////////////////////////////////////////////////////////////////////////////////////////////////////////

WYPopoverController/WYPopoverController.m

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ + (void)load
561561
appearance.innerShadowOffset = CGSizeMake(0, 1);
562562
appearance.innerCornerRadius = 6;
563563
appearance.viewContentInsets = UIEdgeInsetsMake(3, 0, 0, 0);
564+
appearance.overlayColor = [UIColor clearColor];
564565
}
565566
else
566567
{
@@ -591,6 +592,7 @@ + (void)load
591592
appearance.innerShadowOffset = CGSizeZero;
592593
appearance.innerCornerRadius = 0;
593594
appearance.viewContentInsets = UIEdgeInsetsZero;
595+
appearance.overlayColor = [UIColor colorWithWhite:0 alpha:0.15];
594596
}
595597
}
596598
}
@@ -1242,7 +1244,6 @@ @interface WYPopoverController () <WYPopoverOverlayViewDelegate>
12421244
}
12431245

12441246
@property (nonatomic, strong, readonly) UIView *rootView;
1245-
@property (nonatomic, strong, readonly) UIColor *overlayColor;
12461247
@property (nonatomic, assign, readonly) CGSize contentSizeForViewInPopover;
12471248

12481249
- (void)dismissPopoverAnimated:(BOOL)animated callDelegate:(BOOL)callDelegate;
@@ -1310,12 +1311,6 @@ - (UIView *)rootView
13101311
return result;
13111312
}
13121313

1313-
- (UIColor *)overlayColor
1314-
{
1315-
UIColor* result = (WY_IS_IOS_LESS_THAN(@"7.0")) ? [UIColor clearColor] : [UIColor colorWithWhite:0 alpha:0.15];
1316-
return result;
1317-
}
1318-
13191314
- (CGSize)popoverContentSize
13201315
{
13211316
CGSize result = CGSizeZero;
@@ -1399,11 +1394,11 @@ - (void)presentPopoverFromRect:(CGRect)aRect inView:(UIView *)aView permittedArr
13991394
overlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
14001395
overlayView.autoresizesSubviews = NO;
14011396
overlayView.userInteractionEnabled = YES;
1402-
overlayView.backgroundColor = self.overlayColor;
14031397
overlayView.delegate = self;
14041398
overlayView.passthroughViews = passthroughViews;
14051399

14061400
containerView = [[WYPopoverBackgroundView alloc] initWithContentSize:contentViewSize];
1401+
14071402
[overlayView addSubview:containerView];
14081403

14091404
containerView.hidden = YES;
@@ -1443,6 +1438,10 @@ - (void)presentPopoverFromRect:(CGRect)aRect inView:(UIView *)aView permittedArr
14431438
containerView.innerShadowOffset = appearance.innerShadowOffset;
14441439
containerView.innerCornerRadius = appearance.innerCornerRadius;
14451440
containerView.viewContentInsets = appearance.viewContentInsets;
1441+
1442+
overlayView.backgroundColor = appearance.overlayColor;
1443+
} else {
1444+
overlayView.backgroundColor = containerView.overlayColor;
14461445
}
14471446

14481447
[self positionPopover];

0 commit comments

Comments
 (0)