Popover

1.2

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

What's New

1.2

2017-10-09T04:44:27Z

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使用 MIT 许可证,详情见 LICENSE 文件.

Description

  • Swift Tools
View More Packages from this Author

Dependencies

  • None
Last updated: Mon May 06 2024 01:37:08 GMT-0900 (Hawaii-Aleutian Daylight Time)