ios - 如何使用 UIPopoverBackgroundView 在 iOS 6 中呈现透明弹出窗口

标签 ios objective-c uiview ios6 uipopovercontroller

我正在使用 UIPopoverController 在 iOS 6 中呈现一个 UITableViewController

我试图让这个弹出窗口半透明,以便能够显示覆盖的 View 。除此之外,我想要一个带有默认箭头等的标准弹出 Controller 。

从 iOS 5 开始,可以使用 UIPopoverBackgroundView 定义自定义弹出框背景 View 。 . 但是,我正在努力正确设置背景。我用来设置背景 View 的代码如下所示。我想设置仅 alpha 值,并将其他属性设置为默认值。

此外,我还需要如何配置弹出框内显示的 TableView Controller 以使其 View (及其所有 subview ,文本除外)也具有透明度。

谢谢!

configPopover.popoverBackgroundViewClass = [TransparentPopoverBackGroundView class];

TransparentPopoverBackGroundView.m:

#import "TransparentPopoverBackGroundView.h"

@implementation TransparentPopoverBackGroundView

@synthesize arrowOffset;
@synthesize arrowDirection;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.alpha = 0.4;
    }
    return self;
}

+ (UIEdgeInsets)contentViewInsets {
    return UIEdgeInsetsMake(5, 5, 5, 5);
}

+ (CGFloat)arrowHeight{
    return 10.0;
}

+ (CGFloat)arrowBase{
    return 10.0;
}

最佳答案

试试这个 link

设置

#define DEFAULT_TINT_COLOR [UIColor blackColor];

#define DEFAULT_TINT_COLOR [UIColor clearColor];

关于ios - 如何使用 UIPopoverBackgroundView 在 iOS 6 中呈现透明弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15717147/

相关文章:

iphone - UIView 的 -drawRect 是否为 : have to be called on the main thread?

ios - 推送通知在 macOS Catalyst 应用程序上不起作用

ios - 从当前 View 和推送 View 处理后退按钮

ios - 当窗口的 subview 之一被删除时, View 大小自动设置为窗口大小

ios - NSTimer 启动时出现异常

ios - 根据单元格选择,使用 NSArray 中的选择对象重新加载 UITableView

ios - 由于iOS 7, View 不出现

ios - 核心数据复杂关系

ios - UITextView 最多 4 行且总共 140 个字符

ios - 我如何获取在 NSManagedObjectContext 中获取的模型对象的快照,以便在释放上下文后它们可用?