我想创建一个带有白色边框的popover。我已经通过将子类的实例分配给popoverBackgroundViewClass来完成。我能够用白色实现这一点(在背景中使用白色图像),但不会删除弹出框的边框。仍然出现白色边框。有没有办法删除它?
答案 0 :(得分:2)
是的,有一个疯狂的解决方案)在你呈现过去后,你需要调用这个方法
-(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]; } } } } } } } } } } }
答案 1 :(得分:0)
您可以尝试使用此库https://github.com/ddebin/DDPopoverBackgroundView
UIPopoverController *popOver = [[UIPopoverController alloc] initWithContentViewController:content];
[popOver setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
只需设置
[popOver.popoverBackgroundViewClass setContentInset:0.0f];
就是这样。 但请记住,这只适用于 iOS 5 +