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

fix bug when setting titleLabel.shadowColor for REMenuItemView. #121

Open
wants to merge 3 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
1 change: 1 addition & 0 deletions REMenu/REMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ typedef NS_ENUM(NSInteger, REMenuLiveBackgroundStyle) {
@property (assign, readwrite, nonatomic) CGFloat shadowOpacity;
@property (assign, readwrite, nonatomic) CGFloat shadowRadius;
@property (assign, readwrite, nonatomic) CGFloat itemHeight;
@property (assign, readwrite, nonatomic) CGFloat itemWidth;//default -1. If it is less than 0, use rect.width of view instead.
@property (assign, readwrite, nonatomic) CGFloat backgroundAlpha;
@property (strong, readwrite, nonatomic) UIColor *backgroundColor;
@property (strong, readwrite, nonatomic) UIColor *separatorColor;
Expand Down
8 changes: 5 additions & 3 deletions REMenu/REMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ - (id)init
_imageAlignment = REMenuImageAlignmentLeft;
_closeOnSelection = YES;
_itemHeight = 48.0;
_itemWidth = -1;
_separatorHeight = 2.0;
_separatorOffset = CGSizeMake(0.0, 0.0);
_waitUntilAnimationIsComplete = YES;
Expand Down Expand Up @@ -185,6 +186,7 @@ - (void)showFromRect:(CGRect)rect inView:(UIView *)view
});

CGFloat navigationBarOffset = self.appearsBehindNavigationBar && self.navigationBar ? 64 : 0;
const CGFloat itemWidth = self.itemWidth < 0 ? rect.size.width : self.itemWidth;

// Append new item views to REMenuView
//
Expand All @@ -197,15 +199,15 @@ - (void)showFromRect:(CGRect)rect inView:(UIView *)view

UIView *separatorView = [[UIView alloc] initWithFrame:CGRectMake(self.separatorOffset.width,
index * self.itemHeight + index * self.separatorHeight + 40.0 + navigationBarOffset + self.separatorOffset.height,
rect.size.width - self.separatorOffset.width,
itemWidth - self.separatorOffset.width,
self.separatorHeight)];
separatorView.backgroundColor = self.separatorColor;
separatorView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.menuView addSubview:separatorView];

REMenuItemView *itemView = [[REMenuItemView alloc] initWithFrame:CGRectMake(0,
index * self.itemHeight + (index + 1.0) * self.separatorHeight + 40.0 + navigationBarOffset,
rect.size.width,
itemWidth,
itemHeight)
menu:self item:item
hasSubtitle:item.subtitle.length > 0];
Expand All @@ -222,7 +224,7 @@ - (void)showFromRect:(CGRect)rect inView:(UIView *)view

// Set up frames
//
self.menuWrapperView.frame = CGRectMake(0, -self.combinedHeight - navigationBarOffset, rect.size.width, self.combinedHeight + navigationBarOffset);
self.menuWrapperView.frame = CGRectMake(0, -self.combinedHeight - navigationBarOffset, itemWidth, self.combinedHeight + navigationBarOffset);
self.menuView.frame = self.menuWrapperView.bounds;
if (REUIKitIsFlatMode() && self.liveBlur) {
self.toolbar.frame = self.menuWrapperView.bounds;
Expand Down
2 changes: 1 addition & 1 deletion REMenu/REMenuItemView.m
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ - (void)layoutSubviews
self.titleLabel.font = self.item.font == nil ? self.menu.font : self.item.font;
self.titleLabel.text = self.item.title;
self.titleLabel.textColor = self.item.textColor == nil ? self.menu.textColor : self.item.textColor;
self.titleLabel.shadowColor = self.item.textShadowColor ? self.menu.textShadowColor : self.item.textShadowColor;
self.titleLabel.shadowColor = self.item.textShadowColor == nil ? self.menu.textShadowColor : self.item.textShadowColor;
self.titleLabel.shadowOffset = self.item.textShadowOffset.width == 0 && self.item.textShadowOffset.height == 0 ? self.menu.textShadowOffset : self.item.textShadowOffset;
self.titleLabel.textAlignment = (NSInteger)self.item.textAlignment == -1 ? self.menu.textAlignment : self.item.textAlignment;
self.subtitleLabel.font = self.item.subtitleFont == nil ? self.menu.subtitleFont : self.item.subtitleFont
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,29 @@ - (void)viewDidLoad
//self.menu.liveBlur = YES;
//self.menu.liveBlurBackgroundStyle = REMenuLiveBackgroundStyleDark;

self.menu.borderWidth = 0;
self.menu.separatorHeight = 1;
self.menu.separatorColor = [UIColor whiteColor];
self.menu.separatorOffset = CGSizeMake(15.0, 0.0);
self.menu.imageOffset = CGSizeMake(5, -1);
self.menu.highlightedSeparatorColor = [UIColor whiteColor];
self.menu.itemHeight = 50;
self.menu.itemWidth = 300;
self.menu.backgroundColor = [UIColor colorWithRed:0 green:141.0/255 blue:1.0 alpha:1];
self.menu.highlightedBackgroundColor = self.menu.backgroundColor;
self.menu.textColor = [UIColor whiteColor];
self.menu.highlightedTextColor = [UIColor blackColor];
self.menu.textShadowColor = [UIColor clearColor];
self.menu.highlightedTextShadowColor = [UIColor clearColor];
self.menu.font = [UIFont systemFontOfSize:14];

self.menu.waitUntilAnimationIsComplete = NO;
self.menu.badgeLabelConfigurationBlock = ^(UILabel *badgeLabel, REMenuItem *item) {
badgeLabel.backgroundColor = [UIColor colorWithRed:0 green:179/255.0 blue:134/255.0 alpha:1];
badgeLabel.layer.borderColor = [UIColor colorWithRed:0.000 green:0.648 blue:0.507 alpha:1.000].CGColor;
};
self.menu.delegate = self;

homeItem.textColor = [UIColor whiteColor];

[self.menu setClosePreparationBlock:^{
NSLog(@"Menu will close");
Expand All @@ -140,8 +154,8 @@ - (void)toggleMenu
{
if (self.menu.isOpen)
return [self.menu close];

[self.menu showFromNavigationController:self];
[self.menu showFromRect:CGRectMake(0, 64, 300, 480) inView:self.view];
// [self.menu showFromNavigationController:self];
}

#pragma mark - REMenu Delegate Methods
Expand Down