一个为 iOS 设计的美丽的模糊下拉菜单。
这样做最简单的方法是使用 CocoaPods。只需将 `'DCBlurMenu'` 添加到您的 Podfile 中。
如果您想手动安装,则需要
- Clone the git repository and initialize submodules
- Drag the DCBlurMenu into your project
DCBlurMenu 支持 ARC。
目前 DCBlurMenu 依赖于 Storyboards 的使用。设置应包括一个 UINavigationController 和当选中菜单项时显示的视图(确保给它们一个 ID 进行引用)。从 `DCBlurMenuNavigationController` 子类化并实现以下方法
// mandatory
- (void)createMenu;
- (void)selectedItemAtIndex:(NSInteger)index // is triggered upon menu selection
// optional
-(void)menuIsAnimating;
- (void)createMenu
{
// Create Menu Items
DCMenuItem *first = [DCMenuItem new];
first.title = @"First";
first.storyboardID = @"firstView";
DCMenuItem *second = [DCMenuItem new];
second.title = @"Second";
second.storyboardID = @"secondView";
DCMenuItem *third = [DCMenuItem new];
third.title = @"Third";
third.storyboardID = @"thirdView";
DCMenuItem *fourth = [DCMenuItem new];
fourth.title = @"Fourth";
fourth.storyboardID = @"fourthView";
self.menuItems = [[NSArray alloc] initWithObjects:first, second, third, fourth, nil];
// Set starting index
self.startIndex = 0;
self.cellSelectedColor = [UIColor colorWithRed:137/255.f green:224/255.f blue:250/255.f alpha:.4];
self.animationDuration = 0.4f;
self.cellHeight = 70.f;
}
- (void)selectedItemAtIndex:(NSInteger)index
{
NSLog(@"IndexPath Selected: %li", index);
}
将您的 UINavigationController 类设置为它,并设置完成!请确保查看示例项目进行参考。
以下着色属性可用于修改
@property (nonatomic) UIColor *cellSelectedColor;
@property (nonatomic) float animationDuration;
@property (nonatomic) float cellHeight; // default to 70 which only fits 4 items
MIT 许可证 (MIT)
版权所有 © 2014 David Chavez
特此许可,免费向任何获得此软件及其相关文档文件副本(“软件”)的人提供,以不受限制的方式处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本,并允许向提供软件的人授予这样做,但受以下条件约束
上述版权声明和本许可声明应包含在软件的副本或实质性部分中。
本软件按“现状”提供,不提供任何形式的保证,包括但不限于对适销性、特定目的适用性和非侵权的保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论是由于合同行为、侵权或其他行为引起的,无论这些行为是否与软件有关、软件的使用或其他软件的交易方式有关。