NGSPopoverView 1.2.0

NGSPopoverView 1.2.0

测试已测试
Lang语言 Obj-CObjective C
许可 MIT
发布上次发布2017年10月

Paulius Vindzigelskis 维护。



  • 作者:
  • Paulius Vindzigelskis





README

通用简单弹出视图,用于展示任何继承自 UIView 的内容。在 iPhone 和 iPad 上都能使用。易于自定义。

安装

通用

在您的目标中包含 NGSPopoverView .h 和 .m 文件。在需要的地方使用 #import "NGSPopoverView.h"。

常见问题解答

  • 如何将其颜色从白色改为所需颜色?

使用 tintColor 属性。默认值是白色。

  • 我在弹出视图中添加了 UITableView,但它显示的是空的内容。我做错了什么?

NGSPopoverView 使用 AutoLayout 来计算其大小。请为 UITableView 添加高度(必需)和宽度(可选)约束,因为它没有设置 intrinsicContentSize 属性。

示例

圆角

rounded_corner.png

- (IBAction)buttonPressed:(UIButton *)sender {
    UILabel *label = [[UILabel alloc] init];
    label.text = @"Some text\nAnd some more";
    label.numberOfLines = 0;
    
    NGSPopoverView *popover = [[NGSPopoverView alloc] initWithCornerRadius:10.f
                                                                 direction:NGSPopoverArrowPositionAutomatic
                                                                 arrowSize:CGSizeMake(20, 10)];
    popover.contentView = label;
    
    [popover showFromView:sender animated:YES];
}

全屏

fill_screen.png

- (IBAction)buttonPressed:(UIButton *)sender {
    UILabel *label = [[UILabel alloc] init];
    label.text = @"Some text\nAnd some more";
    label.numberOfLines = 0;
    
    NGSPopoverView *popover = [[NGSPopoverView alloc] initWithCornerRadius:0.f
                                                                 direction:NGSPopoverArrowPositionAutomatic
                                                                 arrowSize:CGSizeMake(20, 10)];
    popover.contentView = label;
    popover.fillScreen = YES;
    
    [popover showFromView:sender animated:YES];
}

使用透明度遮罩源视图

mask_view.png

- (IBAction)buttonPressed:(UIButton *)sender {
    UILabel *label = [[UILabel alloc] init];
    label.text = @"Some text\nAnd some more";
    label.numberOfLines = 0;
    
    NGSPopoverView *popover = [[NGSPopoverView alloc] initWithCornerRadius:10.f
                                                                 direction:NGSPopoverArrowPositionAutomatic
                                                                 arrowSize:CGSizeMake(20, 10)];
    popover.contentView = label;
    popover.shouldMaskSourceViewToVisible = YES;
    popover.maskedSourceViewCornerRadius = sender.frame.size.width/2.f;
    
    [popover showFromView:sender animated:YES];
}

Analytics

Hey.lt - Nemokamas lankytojų skaitliukas