ios - UIPopoverPresentationController 无法设置箭头颜色

标签 ios objective-c iphone uipopovercontroller

我正在尝试在 iPhone 上使用 UIPopoverPresentationController 类呈现弹出窗口。 我需要在弹出框内显示导航 Controller 。所以我做了以下事情:

    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
    viewController.preferredContentSize = size;
    navigationController.modalPresentationStyle = UIModalPresentationPopover;
    self.currentPopoverController = navigationController.popoverPresentationController;
    self.currentPopoverController.backgroundColor = [UIColor commonApplicationBgColor];//My common app blue color
    self.view.alpha = 0.7;
    [self presentViewController:navigationController animated:YES completion:nil];

它工作正常,但箭头颜色与弹出导航栏背景颜色不同。我检查过它们使用相同的 [UIColor commonApplicationBgColor],但看起来箭头颜色更深。尝试为 self.currentPopoverController.backgroundColor 设置 alpha,但它仍然有错误的颜色。 请检查图像: enter image description here

最佳答案

如果你不想要箭头那么你可以将 0 传递给 permittedarrowdirection 就像,

[popoverController presentPopoverFromRect:YOUR_RECT
                                inView:self.view 
              permittedArrowDirections:0
                              animated:YES];

更新:

你可以这样设置,

 popover = [[UIPopoverController alloc] initWithContentViewController:contentViewController];
 popover.backgroundColor = contentViewController.view.backgroundColor; 

将背景颜色设置为 popovercontroller。

更新 2:

myPopoverViewController.modalPresentationStyle = UIModalPresentationPopover;
[self presentViewController:myPopoverViewController animated: YES completion: nil];

// Get the popover presentation controller and configure it.
UIPopoverPresentationController *presentationController =
     [myPopoverViewController popoverPresentationController];
 presentationController.permittedArrowDirections =
     UIPopoverArrowDirectionLeft | UIPopoverArrowDirectionRight;
  presentationController.sourceView = myView;
 presentationController.sourceRect = sourceRect;

presentationController.backgroundColor = [UIColor grayColor]; //set your expacted color here.

希望对你有帮助

关于ios - UIPopoverPresentationController 无法设置箭头颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36673561/

相关文章:

ios - 允许 JSQMessagesViewController 中使用更长的用户名

ios - 如何让音乐在所有 View 中继续播放

javascript - 如何防止 iOS uikeyboard 箭头触发的 "tab"操作?

ios - 长按模式下的 Collection View 时,如何移动 Collection View 单元格并在 iOS 中重新排列它们?

objective-c - 在 Objective C 中重新定义/调整 C 数组的大小?

ios - 加速度计低通滤波器平滑

ios - 奇怪但易于理解的错误... UIActivityIndi​​catorView stopAnimating 不起作用

iphone - 单击 iPhone 应用程序中的表格 View 单元格打开相机

ios - 无法将第二个选项卡栏添加到选项卡栏 Controller View

iphone - 在启动时自动实例化单例