测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | Apache 2 |
发布最后发布 | 2015年11月 |
由 Maksim Usenko,Koloda 维护。
查看这个 dribbble项目中
查看这个 Behance项目
![]() |
![]() |
![]() |
![]() |
欢迎您查看示例文件夹中的项目样例,以了解完整的操作。
#import “YALContextMenuTableView.h”
@protocol YALContextMenuCell <NSObject>
- (UIView *)animatedIcon;
- (UIView *)animatedContent;
@end
- (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;
//optional - implement menu items layout
self.contextMenuTableView.menuItemsSide = Right;
self.contextMenuTableView.menuItemsAppearanceDirection = FromTopToBottom;
//register nib
UINib *cellNib = [UINib nibWithNibName:@"ContextMenuCell" bundle:nil];
[self.contextMenuTableView registerNib:cellNib forCellReuseIdentifier:@"contextMenuCellReuseId"];
}
// it is better to use this method only for proper animation
[self.contextMenuTableView showInView:self.navigationController.view withEdgeInsets:UIEdgeInsetsZero animated:YES];
}
updateAlongsideRotation
方法,或在旋转动画完成后或在UIViewControllerTransitionCoordinator的animateAlongsideTransition
块中调用reloadData
方法,以进行适当的旋转动画。- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
//should be called after rotation animation completed
[self.contextMenuTableView reloadData];
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
[self.contextMenuTableView updateAlongsideRotation];
}
- (void)viewWillTransitionToSize:(CGSize)size
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[coordinator animateAlongsideTransition:nil completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
//should be called after rotation animation completed
[self.contextMenuTableView reloadData];
}];
[self.contextMenuTableView updateAlongsideRotation];
}
为了自定义菜单项的边侧位置,您可以指定一个'menuItemsSide'属性。当将其设置为'Right'时,第一个单元格将从右向左打开,被选中的单元格将相反关闭。当将其设置为'Left'时,第一个单元格将从左向右打开,反向关闭被选中的单元格。默认 - Right。
此外,为了自定义菜单项的显示方向,您可以指定'menuItemsAppearanceDirection'属性。默认 - FromTopToBottom。
为了自定义单元格,您可以在动画图标中设置自己的自定义可绘制的。实际上,单元格的设计和布局完全由您决定。
animationDuration用于动画速度,单位为秒。
iOS 7, iOS 8, iOS 9
版权所有 2015,Yalantis
根据Apache许可证版本2.0(“许可证”);除非您遵守该许可证,否则不得使用此文件。您可以在[此处](https://apache.ac.cn/licenses/LICENSE-2.0)获得许可证副本。
https://apache.ac.cn/licenses/LICENSE-2.0
除非适用法律要求或书面同意,否则根据本许可发布的软件“现状”提供,不提供任何形式的明示或暗示保证。有关许可下授权和限制的具体语言,请参阅许可协议。