HTMenu 是一个菜单容器,为具体显示的内容提供显示、隐藏动画和位置决策。
利用子类实现(HTArrowMenuLocationDecider)
_decider = [[HTArrowMenuLocationDecider alloc] init];
CGRect rect = [UIScreen mainScreen].bounds;
//设置约束矩形,即menu的显示区域,默认为[UIScreen mainScreen].bounds
_decider.limitBounds = CGRectMake(10, 10, rect.size.width-20, rect.size.height-20);
//设置menu位置优先级,也可使用默认优先级
_decider.positionPriority = @[@(HTMenuPositionLeft)];
利用子类实现(HTArrowBoxMenu)
_menu = [[HTArrowBoxMenu alloc] initWithFrame:CGRectMake(0, 0, 130, 166) locationDecider:_decider];
//设置箭头大小
[_menu setArrowAngle:90 arrowHeight:6];
利用子类实现(HTMenuAlphaAnimator)
HTMenu *menu = [HTMenu alloc] init];
_animator = [[HTMenuAlphaAnimator alloc] initWithMenu:menu];
_animator.duration = 0.5;
_menu.animator = animator;
UITableView *tableView = [[UITableView alloc] init];
tableView.dataSource = self; // liuchang datasource 考虑改成小写
tableView.delegate = self;
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
tableView.backgroundColor = [UIColor clearColor];
tableView.scrollEnabled = NO;
[tableView registerClass:[HTImageAndTextTableViewCell class] forCellReuseIdentifier:NSStringFromClass([HTImageAndTextTableViewCell class])];
//添加具体显示内容,如果有箭头会根据箭头调整位置和大小
[_menu addMenuDetailView:tableView];
//注意:FromRect的位置信息是相对于[UIScreen mainScreen].bounds而设置的
[_menu showFromRect:CGRect(100,100,50,50)];
//可以使用UIView+HTMenu的helper接口
- (void)showMenu:(HTMenu *)menu
//外部调用hide
[_menu hide];
//HTArrowBoxMenu默认提供显示在window上面,并且提供点击空白位置隐藏menu的功能
该项目最低支持 iOS 7.0 和 Xcode 7.0
HTMenu,详情见 LICENSE 文件。