我正在尝试更改通过storyboard segue定义(而不是通过编程构建)从按钮弹出的默认弹出窗箭头颜色。以下图片显示了白色默认弹出框箭头:
当我添加以下代码时:
将以下内容添加到呈现在弹出窗口中的
我希望有一个简单的解决方法(使用与弹出窗口相同的storyboard segue)来解决这个常见问题。
navigationController?.popoverPresentationController?.backgroundColor = myNavBarColor
将以下内容添加到呈现在弹出窗口中的
UIViewController
的viewWillAppear
方法中,结果如下所示:
在主要的UIViewController
的prepareForSegue
方法中为UIPopoverPresentationController
定义一个新的UIPopoverBackgroundView
类是“太晚了”。我希望有一个简单的解决方法(使用与弹出窗口相同的storyboard segue)来解决这个常见问题。
prepareForSegue
中设置背景颜色,可使用以下代码:segue.destinationViewController.popoverPresentationController.backgroundColor
。 - gabblersegue.destination.modalPresentationStyle = .popover
,否则segue.destination.popoverPresentationController
将为nil
。除此之外,该解决方案运行良好。 - iStefo