0

我已經在界面生成器中成功連接了幾個彈窗視圖。我試圖通過將背景顏色設置爲黑色來使背景變黑,但我仍然在彈出窗口上獲得了一個白色箭頭,並且在四個圓角上出現了白色僞影。在界面生成器中製作彈出窗口背景黑色

請看截圖。

enter image description here

我能做些什麼使背景界面生成器全黑?

我很欣賞下面的答案,但我仍然不能完全得到它的工作 - 這是我的代碼:

// 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]; 
     } 
    } 

回答

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]; 
     } 
1

您不能自定義由IB那個箭頭。你將需要一個完全定製的popover。其中有很多可用於git。但是如果你想使用默認的那個,那麼也不可能自定義那個箭頭。

+0

所以我發現這一點:https://github.com/ddebin/DDPopoverBackgroundView。但是我可以將它與界面構建器一起使用嗎?我似乎無法弄清楚如何在界面構建器中設置popoverBackgroundViewClass。 – PhilBot

相關問題