通用简单弹出视图,用于展示任何继承自 UIView 的内容。在 iPhone 和 iPad 上都能使用。易于自定义。
在您的目标中包含 NGSPopoverView .h 和 .m 文件。在需要的地方使用 #import "NGSPopoverView.h"。
使用 tintColor 属性。默认值是白色。
NGSPopoverView 使用 AutoLayout 来计算其大小。请为 UITableView 添加高度(必需)和宽度(可选)约束,因为它没有设置 intrinsicContentSize 属性。
- (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];
}
- (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];
}
- (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];
}