FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

DeadRabbit2016/CJTopScrollViewMenu: 类京东、头条、严选等头部的标签选择器~ · GitHub

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

效果图

代码介绍

  • 将项目中 CJTopScollViewMenu 文件夹导入工程
  • 导入 #import "CJTopScrollMenu.h" 头文件

使用举例

//1.初始化topScrollMenu
self.topScrollMenu = [CJTopScrollMenu topScrollMenuWithFrame:CGRectMake(0, 64, self.view.frame.size.width - AddButtonWidth, 44)];
_topScrollMenu.titlesArr = [NSArray arrayWithArray:_titles];
_topScrollMenu.topScrollMenuDelegate = self;
[self.view addSubview:_topScrollMenu];

// 2.添加右侧折叠按钮
UIButton * foldButton = [UIButton buttonWithType:UIButtonTypeCustom];
foldButton.frame = CGRectMake(self.topScrollMenu.CJ_right, 64, 44, 44);
[foldButton setImage:[UIImage imageNamed:@"jshop_category_arrow_down"] forState:UIControlStateNormal];
foldButton.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.9];
foldButton.layer.shadowOffset = CGSizeMake(-2, 0);
foldButton.layer.shadowColor = [UIColor lightGrayColor].CGColor;
//    foldButton.layer.shadowRadius = 4;
foldButton.layer.shadowOpacity = 1.0;
[foldButton addTarget:self action:@selector(showAllMenus:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:foldButton];
self.rightFoldButton = foldButton;

代理方法

#pragma mark title 被点击时调用的代理方法
-(void)CJTopScrollMenu:(CJTopScrollMenu *)topScrollMenu didSelectTitleAtIndex:(NSInteger)index{
// 1 计算滚动的位置
CGFloat offsetX = index * self.view.frame.size.width;
self.mainScrollView.contentOffset = CGPointMake(offsetX, 0);

// 2.给对应位置添加对应子控制器
[self showVc:index];
}

#pragma mark title 右侧折叠按钮被点击时调用的代理方法
- (void)CJAllMenuView:(CJAllMenuView *)allMenuView didSelectTitleAtIndex:(NSInteger)index{
[UIView animateWithDuration:0.1 animations:^{
[_topScrollMenu selectLabel:_topScrollMenu.allTitleLabel[index]];
_coverView.hidden = YES;
}];
}

写在最后

About

类京东、头条、严选等头部的标签选择器~

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages


Back | FazBrowse Home | New Git URL