Giter Club home page Giter Club logo

popover's Introduction

Popover

###一款优雅好用的类似QQ和微信消息页面的右上角微型菜单弹窗, 最低支持iOS6

该弹窗控件有白色和黑色这两种风格, 使用方法也非常简单, 和系统的UIAlertController差不多的使用方法, 你只需要设置好对应的action和设定好弹窗箭头要指向的点(CGPoint)或者要指向的控件即可, 该弹窗控件会自动计算箭头指向和弹出位置

所有效果如下图:

Alt text

该弹窗有两种风格:

白色风格: PopoverViewStyleDefault (默认为此风格)

Alt text

黑色风格: PopoverViewStyleDark

Alt text

可以设置图片也可以不设置图片:

- (IBAction)showWithoutImage:(UIButton *)sender {
    PopoverAction *action1 = [PopoverAction actionWithTitle:@"Title" handler:^(PopoverAction *action) {
        // 该Block不会导致内存泄露, Block内代码无需刻意去设置弱引用.
    }];
    ...
    PopoverView *popoverView = [PopoverView popoverView];
    popoverView.style = PopoverViewStyleDark;
    [popoverView showToView:sender withActions:@[action1, ...]];
}

Alt text

也可以设置在弹出窗口时显示背景阴影层:

- (IBAction)rightButtonAction:(UIButton *)sender {
    PopoverView *popoverView = [PopoverView popoverView];
    popoverView.showShade = YES; // 显示阴影背景
    [popoverView showToView:sender withActions:@[...]];
}

Alt text

使用方法: (将PopoverView文件夹拖到你的项目中然后 #import "PopoverView.h" )

// 附带左边图标的
PopoverAction *action1 = [PopoverAction actionWithImage:Image title:@"Title" handler:^(PopoverAction *action) {
    // 该Block不会导致内存泄露, Block内代码无需刻意去设置弱引用.
}];
// 纯标题的
PopoverAction *action1 = [PopoverAction actionWithTitle:@"Title" handler:^(PopoverAction *action) {
    // 该Block不会导致内存泄露, Block内代码无需刻意去设置弱引用.
}];
...
PopoverView *popoverView = [PopoverView popoverView];
//popoverView.showShade = YES; // 显示阴影背景
//popoverView.style = PopoverViewStyleDark; // 设置为黑色风格
//popoverView.hideAfterTouchOutside = NO; // 点击外部时不允许隐藏
// 有两种显示方法
// 1. 显示在指定的控件
[popoverView showToView:sender withActions:@[action1, ...]];
// 2. 显示在指定的点(CGPoint), 该点的坐标是相对KeyWidnow的坐标.
[popoverView showToPoint:CGPointMake(20, 64) withActions:@[action1, ...]];

LICENSE

PopoverView is available under the MIT license. See the LICENSE file for more info.

popover's People

Contributors

lifution avatar

Watchers

 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.