0

我已经成功地在界面生成器中连接了几个弹出视图。我试图通过将视图背景颜色设置为黑色来使背景变黑,但我仍然在弹出框本身上看到一个白色箭头,在 4 个圆角上看到白色伪影。

请看截图。

在此处输入图像描述

我该怎么做才能在界面生成器中使背景完全变黑?

我很欣赏下面的答案,但我仍然无法让它工作 - 这是我的代码:

// Show the satellite Ephemeris
    if ( itemIndex == 1 ) {

        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
            NSLog(@"This is an iPad - Creating popover!");
            EphemerisDataView *ephemView = [[EphemerisDataView alloc] init];
            UIPopoverController *popOver = [[UIPopoverController alloc] initWithContentViewController:ephemView];
            [popOver setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
            [popOver.popoverBackgroundViewClass setTintColor:[UIColor blackColor]];
            CGSize size = CGSizeMake(320, 480); // size of view
            popOver.popoverContentSize = size;
            [popOver presentPopoverFromRect:self.popOverAnchor.bounds inView:self.view
                             permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

        }
        else {
            NSLog(@"This is not an iPad - Performing segue...");
            // Show the next view
            [self performSegueWithIdentifier:@"Ephemeris" sender:self];
        }
    }
4

2 回答 2

1

您无法通过 IB 自定义该箭头。您将需要一个完全定制的弹出框。其中很多都可以在 git 上找到。但是,如果您想使用默认箭头,则也无法自定义该箭头。

于 2013-11-10T05:57:28.557 回答
0

像这样做:

        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {

            NSLog(@"This is an iPad - Creating popover!");
            UIStoryboard *storyboard = [UIStoryboard storyboardWithName: @"MainStoryboard_iPad" bundle:[NSBundle mainBundle]];
            EphemerisDataView *ephemView = [storyboard instantiateViewControllerWithIdentifier:@"EphemerisDataView"];
            UIPopoverController *popOver = [[UIPopoverController alloc] initWithContentViewController:ephemView];
            self.customPopoverController = popOver;
            [popOver setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
            [popOver.popoverBackgroundViewClass setTintColor:[UIColor blackColor]];
            popOver.delegate = self;
            CGSize size = CGSizeMake(320, 480); // size of view
            popOver.popoverContentSize = size;
            [popOver presentPopoverFromRect:self.popOverAnchor.bounds inView:self.popOverAnchor
                             permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

        }
        else {
            NSLog(@"This is not an iPad - Performing segue...");
            // Show the next view
            [self performSegueWithIdentifier:@"Ephemeris" sender:self];
        }
于 2013-11-13T00:11:09.517 回答