0

我想创建一个带有白色边框的弹出框。我已经通过将子类的实例分配给 popoverBackgroundViewClass 来完成。我可以用白色(在背景上使用白色图像)来实现这一点,但不会删除弹出框的边框。白色边框仍然出现。有什么办法可以去掉吗?

4

2 回答 2

2

是的,有一个疯狂的解决方案)在你呈现Popover之后,你需要调用这个方法

-(void)removeInnerShadow {
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];

for (UIView *windowSubView in window.subviews) {
    if ([NSStringFromClass([windowSubView class]) isEqualToString:@"UIDimmingView"]) {
        for (UIView *dimmingViewSubviews in windowSubView.subviews) {
            for (UIView *popoverSubview in dimmingViewSubviews.subviews) {
                if([NSStringFromClass([popoverSubview class]) isEqualToString:@"UIView"]) {
                    for (UIView *subviewA in popoverSubview.subviews) {
                        if ([NSStringFromClass([subviewA class]) isEqualToString:@"UILayoutContainerView"]) {
                            subviewA.layer.cornerRadius = 0;
                        }

                        for (UIView *subviewB in subviewA.subviews) {
                            if ([NSStringFromClass([subviewB class]) isEqualToString:@"UIImageView"] ) {
                                [subviewB removeFromSuperview];
                            }
                            if ([NSStringFromClass([subviewB class]) isEqualToString:@"UILayoutContainerView"] ) {
                                for (UIView *subviewC in subviewB.subviews) {
                                    if ([NSStringFromClass([subviewC class]) isEqualToString:@"UIImageView"]) {
                                        [subviewC removeFromSuperview];
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
}
于 2013-02-15T15:29:09.927 回答
0

你可以试试这个库https://github.com/ddebin/DDPopoverBackgroundView

UIPopoverController *popOver = [[UIPopoverController alloc] initWithContentViewController:content];
[popOver setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];

刚刚设置

[popOver.popoverBackgroundViewClass setContentInset:0.0f];

而已。但请记住,这仅适用于iOS 5+

于 2013-08-29T10:23:01.693 回答