TFDropDownMenu
- 包含一些视图样式的下拉菜单
- github地址: https://github.com/554994782/TFDropDownMenu
Contents
-
支持版本
- ARC
- iOS>=8.0
- iPhone \ iPad screen anyway
-
如何使用TFDropDownMenu
- 使用CocoaPods:
pod TFDropDownMenu
- 其他方式:
- 将
TFDropDownMenu
文件夹拖入工程当中 - 引用:
import "TFDropDownMenu.h"
- 将
- 使用CocoaPods:
-
文件
TFDropDownMenuView.h TFDropDownMenuView.m TFMenuDefinition.h TFMenuDefinition.m TFIndexPatch.h TFIndexPatch.m TFDropDownMenuCollectionViewCell.h TFDropDownMenuCollectionViewCell.m
例子
-
例子效果图
NSMutableArray *array1 = [NSMutableArray arrayWithObjects:@"面积最大", @"面积最小", @"价格最高", @"价格最低", nil];
NSMutableArray *array2 = [NSMutableArray arrayWithObjects:@"热门推荐", @"美食", @"影院", @"自助餐", @"景区", @"汽车", @"网吧", @"游戏", nil];
NSMutableArray *array3 = [NSMutableArray arrayWithObjects:@"从大到小", @"从小到大", @"从高到低", @"从低到高", @"从右到左", @"从左到右", @"从前到后", @"从后到前", nil];
NSArray *array21 = @[
@[@"好玩的", @"好吃的", @"好景的", @"好喝的", @"好唱的"],
@[@"美食城1",@"美食城2", @"美食城3", @"美食城5", @"美食城10"],
@[@"金逸影院", @"万达影院", @"兄弟影院", @"新影联影院", @"保利影院", @"大地影院"],
@[@"韩式烤肉", @"日式自助", @"海底捞", @"湘十二楼", @"金百万"],
@[@"长城", @"故宫", @"天安门", @"明十三陵", @"颐和园", @"圆明园"],
@[@"玛莎拉蒂", @"法拉利", @"奔驰", @"宝马", @"奥迪"],
@[@"休闲网咖", @"学子网吧"],
@[@"英雄联盟", @"王者荣耀", @"大吉大利", @"大话西游", @"传奇"]
];
NSMutableArray *data1 = [NSMutableArray arrayWithObjects:array1, array2, array3, @[@"自定义"], nil];
NSMutableArray *data2 = [NSMutableArray arrayWithObjects:@[], array21, @[], @[], nil];
TFDropDownMenuView *menu = [[TFDropDownMenuView alloc] initWithFrame:CGRectMake(0, NAVBAR_HEIGHT, UIScreen.mainScreen.bounds.size.width, 40) firstArray:data1 secondArray:data2];
menu.delegate = self;
menu.cellSelectBackgroundColor = [UIColor colorWithWhite:0.9 alpha:1];
menu.ratioLeftToScreen = 0.35;
[self.view addSubview:menu];
/*副标*/
NSMutableArray *detail1 = [NSMutableArray arrayWithObjects:@"21", @"22", @"23", @"24", nil];
NSMutableArray *detail2 = [NSMutableArray arrayWithObjects:@"11", @"12", @"13", @"14", @"15", @"16", @"17", @"18", nil];
NSMutableArray *detail3 = [NSMutableArray arrayWithObjects:@"31", @"32", @"33", @"34", @"35", @"36", @"37", @"38", nil];
NSArray *detail21 = @[
@[@"111", @"112", @"113", @"114", @"115"],
@[@"121",@"122", @"123", @"125", @"125"],
@[@"131", @"132", @"133", @"134", @"135", @"136"],
@[@"141", @"142", @"143", @"144", @"145"],
@[@"151", @"152", @"153", @"154", @"155", @"156"],
@[@"161", @"162", @"163", @"164", @"165"],
@[@"171", @"172"],
@[@"181", @"182", @"183", @"184", @"185"]
];
menu.firstRightArray = [NSMutableArray arrayWithObjects:detail1, detail2, detail3, nil];
menu.secondRightArray = [NSMutableArray arrayWithObjects:@[], detail21, nil];
/*风格*/
menu.menuStyleArray = [NSMutableArray arrayWithObjects:[NSNumber numberWithInteger:TFDropDownMenuStyleTableView], [NSNumber numberWithInteger:TFDropDownMenuStyleTableView], [NSNumber numberWithInteger:TFDropDownMenuStyleCollectionView], [NSNumber numberWithInteger:TFDropDownMenuStyleCustom], nil];
/*自定义视图*/
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 300)];
label.text = @"我是自定义视图\n我是自定义视图\n我是自定义视图\n我是自定义视图\n我是自定义视图\n我是自定义视图\n我是自定义视图\n我是自定义视图";
label.numberOfLines = 0;
label.backgroundColor = [UIColor whiteColor];
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor orangeColor];
menu.customViews = [NSMutableArray arrayWithObjects:[NSNull null], [NSNull null], [NSNull null], label, nil];
- 其他公开属性
/**一级菜单右侧小title数组*/
@property (strong, nonatomic) NSMutableArray *firstRightArray;
/**二级菜单右侧小title数组*/
@property (strong, nonatomic) NSMutableArray *secondRightArray;
/**一级菜单左侧icon数组*/
@property (strong, nonatomic) NSMutableArray *firstImageArray;
/**二级菜单左侧icon数组*/
@property (strong, nonatomic) NSMutableArray *secondImageArray;
/**各个菜单风格数组, 默认都为TFDropDownMenuStyleTableView*/
@property (strong, nonatomic) NSMutableArray *menuStyleArray;
//MARK: 公开属性
/**menu背景颜色, 默认白色*/
@property (strong, nonatomic) UIColor *menuBackgroundColor;
/**Item选中字体颜色, 默认橙红色*/ //UIColor = UIColor(red: 246/255.0, green: 79/255.0, blue: 0/255.0, alpha: 1)
@property (strong, nonatomic) UIColor *itemTextSelectColor;
/**Item未选中字体颜色, 默认黑色*/
@property (strong, nonatomic) UIColor *itemTextUnSelectColor;
/**cell选中字体颜色, 默认橙红色*/
@property (strong, nonatomic) UIColor *cellTextSelectColor;
/**cell未选中字体颜色, 默认黑色*/
@property (strong, nonatomic) UIColor *cellTextUnSelectColor;
/**分割线颜色, 默认灰色*/
@property (strong, nonatomic) UIColor *separatorColor;
/**cell选中背景颜色, 默认白色*/
@property (strong, nonatomic) UIColor *cellSelectBackgroundColor;
/**cell未选中背景颜色, 默认白色*/
@property (strong, nonatomic) UIColor *cellUnselectBackgroundColor;
/**Item字体大小, 默认14*/
@property (assign, nonatomic) CGFloat itemFontSize;
/**cell字体大小, 默认14*/
@property (assign, nonatomic) CGFloat cellTitleFontSize;
/**cell右侧副字体大小, 默认11*/
@property (assign, nonatomic) CGFloat cellDetailTitleFontSize;
/**下拉表单高度, 默认300*/
@property (assign, nonatomic) CGFloat tableViewHeight;
/**cell高度, 默认44*/
@property (assign, nonatomic) CGFloat cellHeight;
/**左侧表单宽度占屏比 范围0.0~1.0, 默认0.5*/
@property (assign, nonatomic) CGFloat ratioLeftToScreen;//有二级菜单时调整左右所占比例
/**自定义下拉视图*/
@property (strong, nonatomic) NSMutableArray *customViews;
/**动画时间, 默认0.25*/
@property (assign, nonatomic) CGFloat kAnimationDuration;
-
不同风格效果图