微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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的应用.

原文地址:https://www.jb51.cc/iOS/337162.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐