Skip to content

z624821876/Popover

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Popover

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

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

支持使用CocoaPods导入, Podfile文件中添加:
pod 'Popover.OC'

所有效果如下图:

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 99.2%
  • Ruby 0.8%