Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual effects blur #116

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion REMenu/REMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ @interface REMenu ()
@property (strong, readwrite, nonatomic) NSMutableArray *itemViews;
@property (weak, readwrite, nonatomic) UINavigationBar *navigationBar;
@property (strong, readwrite, nonatomic) UIToolbar *toolbar;
@property (strong, readwrite, nonatomic) UIVisualEffectView *blurView;

@end

Expand Down Expand Up @@ -159,6 +160,31 @@ - (void)showFromRect:(CGRect)rect inView:(UIView *)view
toolbar.layer.masksToBounds = YES;
toolbar;
});

// Add blur view for ios8
self.blurView = ({
UIBlurEffect *effect;
switch (self.liveBlurBackgroundStyle) {
case REMenuLiveBackgroundStyleDark:
effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
break;
case REMenuLiveBackgroundStyleLight:
effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
break;
default:
effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
break;
}
UIVisualEffectView *blurView = [[UIVisualEffectView alloc] initWithEffect:effect];
if ([blurView respondsToSelector:@selector(setBarTintColor:)])
[blurView performSelector:@selector(setBarTintColor:) withObject:self.liveBlurTintColor];
blurView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
blurView.layer.cornerRadius = self.cornerRadius;
blurView.layer.borderColor = self.borderColor.CGColor;
blurView.layer.borderWidth = self.borderWidth;
blurView.layer.masksToBounds = YES;
blurView;
});
}

self.menuWrapperView = ({
Expand Down Expand Up @@ -226,14 +252,20 @@ - (void)showFromRect:(CGRect)rect inView:(UIView *)view
self.menuView.frame = self.menuWrapperView.bounds;
if (REUIKitIsFlatMode() && self.liveBlur) {
self.toolbar.frame = self.menuWrapperView.bounds;
self.blurView.frame = self.menuWrapperView.bounds;
}
self.containerView.frame = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
self.backgroundButton.frame = self.containerView.bounds;

// Add subviews
//
if (REUIKitIsFlatMode() && self.liveBlur) {
[self.menuWrapperView addSubview:self.toolbar];
// If we're in iOS8 use the UIVisualEffectView else use toolbar
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1) {
[self.menuWrapperView addSubview:self.blurView];
} else {
[self.menuWrapperView addSubview:self.toolbar];
}
}
[self.menuWrapperView addSubview:self.menuView];
[self.containerView addSubview:self.backgroundButton];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ - (void)viewDidLoad
// Blurred background in iOS 7
//
//self.menu.liveBlur = YES;
//self.menu.liveBlurBackgroundStyle = REMenuLiveBackgroundStyleDark;
//self.menu.liveBlurBackgroundStyle = REMenuLiveBackgroundStyleLight;

self.menu.separatorOffset = CGSizeMake(15.0, 0.0);
self.menu.imageOffset = CGSizeMake(5, -1);
Expand Down