ios – 自定义UIPopoverBackgroundView:没有阴影

我使用这个好的 tutorial来创建一个自定义的UIPopoverBackgroundView类.

它工作得很好唯一的问题是我没有得到典型的UIPopoverController下降阴影,我想要它.我尝试在我的UIPopoverBackgroundView实例的层上指定它,而不成功.我的UIPopoverController实例似乎没有公开的操作视图.将其添加到popover内容也不起作用.

可能真的很简单:如何在使用自定义UIPopoverBackgroundView类时添加阴影?

// UIPopoverBackgroundView.m

-(id)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        _borderImageView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"bg-popover.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(CAP_INSET,CAP_INSET,CAP_INSET)]];

        _arrowView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg-popover-arrow.png"]];

        [self addSubview:_borderImageView];
        [self addSubview:_arrowView];

        self.layer.shadowOffset = CGSizeMake(50,50);
        self.layer.shadowColor = [[UIColor blackColor] CGColor];
    }

    return self;
}

解决方法

你不需要添加自己的阴影.基本的UIPopoverBackgroundView将为您做.只需确保在您的layoutSubviews实现中调用super.

编辑:我的评论适用于iOS 6的应用.

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...