Skip to content

Commit

Permalink
不止局限于Nav。任意点弹出,自适应方向,自适应指示位置,依然是动态菜单。
Browse files Browse the repository at this point in the history
  • Loading branch information
KongPro committed Jan 17, 2017
1 parent 8c394e7 commit 7bc8f3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Binary file not shown.
10 changes: 6 additions & 4 deletions PopMenuTableView/CommonMenuView.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,19 @@ - (void)setUpUI{
[self addSubview:tableView];
[[UIApplication sharedApplication].keyWindow addSubview:self];
}

#pragma mark --- TableView DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.menuDataArray.count;
}

- (MenuTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
MenuModel *model = self.menuDataArray[indexPath.row];
MenuTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MenuTableViewCell class]) forIndexPath:indexPath];
cell.menuModel = model;
cell.backgroundColor = [UIColor clearColor];
return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
MenuModel *model = self.menuDataArray[indexPath.row];
Expand All @@ -107,6 +109,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
}

#pragma mark --- 关于菜单展示
- (void)displayAtPoint:(CGPoint)point{

point = [self.superview convertPoint:point toView:self.window];
Expand Down Expand Up @@ -152,7 +155,6 @@ - (void)displayAtPoint:(CGPoint)point{
}];
}


- (void)adjustPosition:(CGPoint)point{
self.x = point.x - self.width * 0.5;
self.y = point.y + kMargin;
Expand All @@ -164,7 +166,6 @@ - (void)adjustPosition:(CGPoint)point{
self.layer.affineTransform = CGAffineTransformMakeScale(1.0, 1.0);
}


- (void)updateFrameForMenu{
CommonMenuView *menuView = [[UIApplication sharedApplication].keyWindow viewWithTag:kMenuTag];
menuView.maxValueForItemCount = menuView.menuDataArray.count;
Expand All @@ -176,6 +177,7 @@ - (void)updateFrameForMenu{
}

- (void)hiddenMenu{
self.contentTableView.contentOffset = CGPointMake(0, 0);
[UIView animateWithDuration:0.25 animations:^{
self.layer.affineTransform = CGAffineTransformMakeScale(0.01, 0.01);
self.alpha = 0;
Expand Down Expand Up @@ -217,7 +219,7 @@ - (CAShapeLayer *)getBorderLayer{
return borderLayer;
}

#pragma mark -- 类方法
#pragma mark --- 类方法封装
+ (CommonMenuView *)createMenuWithFrame:(CGRect)frame target:(UIViewController *)target dataArray:(NSArray *)dataArray itemsClickBlock:(void(^)(NSString *str, NSInteger tag))itemsClickBlock backViewTap:(void(^)())backViewTapBlock{

CGFloat menuWidth = frame.size.width ? frame.size.width : 120;
Expand Down

0 comments on commit 7bc8f3a

Please sign in to comment.