源码简介
可以为app的菜单添加漂亮的动画内容,可以自定义icon和title,可根据自己喜好设计单元格和布局。
源码运行截图
源码片段:
- - (IBAction)presentMenuButtonTapped:(UIBarButtonItem *)sender {
- // init YALContextMenuTableView tableView
- if (!self.contextMenuTableView) {
- self.contextMenuTableView = [[YALContextMenuTableView alloc]initWithTableViewDelegateDataSource:self];
- self.contextMenuTableView.animationDuration = 0.15;
- //optional - implement custom YALContextMenuTableView custom protocol
- self.contextMenuTableView.yalDelegate = self;
- //register nib
- UINib *cellNib = [UINib nibWithNibName:@"ContextMenuCell" bundle:nil];
- [self.contextMenuTableView registerNib:cellNib forCellReuseIdentifier:menuCellIdentifier];
- }
- // it is better to use this method only for proper animation
- [self.contextMenuTableView showInView:self.navigationController.view withEdgeInsets:UIEdgeInsetsZero animated:YES];
- }
- #pragma mark - Local methods
- - (void)initiateMenuOptions {
- self.menuTitles = @[@"",
- @"Send message",
- @"Like profile",
- @"Add to friends",
- @"Add to favourites",
- @"Block user"];
- self.menuIcons = @[[UIImage imageNamed:@"Icnclose"],
- [UIImage imageNamed:@"SendMessageIcn"],
- [UIImage imageNamed:@"LikeIcn"],
- [UIImage imageNamed:@"AddToFriendsIcn"],
- [UIImage imageNamed:@"AddToFavouritesIcn"],
- [UIImage imageNamed:@"BlockUserIcn"]];
- }