ios – 自定义UIPopoverBackgroundView:没有阴影

前端之家收集整理的这篇文章主要介绍了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;
}
@H_301_11@解决方法
你不需要添加自己的阴影.基本的UIPopoverBackgroundView将为您做.只需确保在您的layoutSubviews实现中调用super.

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

原文链接:https://www.f2er.com/iOS/337162.html

猜你在找的iOS相关文章