Giter VIP home page Giter VIP logo

dnpopmenu's Introduction

DNPopMenu

弹出菜单,类似QQ那种样式的 snapshot

###使用方法

添加头文件

####实际使用过程中只需要修改menuArray中的项目为自己需要的栏目即可

- (DNPopMenu *)popMenu {
    if (!_popMenu) {
        
        NSMutableArray *popMenuItems = [[NSMutableArray alloc] initWithCapacity:6];
        
        NSArray *menuArray = @[@{@"image":@"contacts_add_newmessage", @"title":@"发起群聊"},
                               @{@"image":@"contacts_add_friend", @"title":@"添加朋友"},
                               @{@"image":@"contacts_add_scan", @"title":@"扫一扫"},
                               @{@"image":@"contacts_add_photo", @"title":@"拍照分享"},
                               @{@"image":@"contacts_add_voip", @"title":@"视频聊天"}
                               ];
        
        [menuArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            NSString *imageName = [NSString stringWithFormat:@"PopMenu.bundle/%@", [obj objectForKey:@"image"]];
            NSString *title = [obj objectForKey:@"title"];
            
            DNPopMenuItem *popMenuItem = [[DNPopMenuItem alloc] initWithImage:[UIImage imageNamed:imageName] title:title];
            [popMenuItems addObject:popMenuItem];
        }];
        
        _popMenu = [[DNPopMenu alloc] initWithMenus:popMenuItems];
        _popMenu.popMenuDidSlectedCompled = ^(NSInteger index, DNPopMenuItem *popMenuItems) {
            NSLog(@"点击的是第%ld个,名字是%@", (long)index, popMenuItems.title);
        };
    }
    return _popMenu;
}

显示Menu

[self.popMenu showMenuAtPoint:CGPointZero];

####注意事项 处理ios7之后cell下移问题 ,在controller中添加适配代码

 if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)]) {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }

具体用法看Demo即可

dnpopmenu's People

Contributors

626600815 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.