25

标题真的说明了一切。我有一个视图控制器连接到一个按钮作为弹出窗口。视图控制器的背景颜色为灰色,但指向按钮的箭头颜色为白色。任何帮助将非常感激。

4

5 回答 5

41

这是我解决它的方法:

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

这会将弹出框与内容背景的颜色相匹配。

于 2014-01-16T00:55:59.280 回答
19

for ios 9.0 + (cpvc is your ViewController)

cpvc.popoverPresentationController.backgroundColor = cpvc.view.backgroundColor;
于 2016-05-26T00:43:12.933 回答
5

你用的是IOS7 SDK吗?

也许你可以试试:

[popover setBackgroundColor:[UIColor whiteColor]];

并确保将内容视图控制器的背景颜色设置为白色。

于 2013-10-30T19:25:26.730 回答
3

迅捷4.2

navController?.popoverPresentationController?.backgroundColor = .black
于 2018-08-31T09:08:44.270 回答
1

我在 iOS7 中遇到了同样的问题(丑陋的白色“箭头”)。这似乎为我解决了这个问题。UIPopoverController 不支持 iOS7 之前的 setBackgroundColor,因此检查。

if ([popoverController respondsToSelector:@selector(setBackgroundColor:)])
{
   [popoverController setBackgroundColor:[UIColor clearColor]];
}
于 2014-04-26T00:10:45.683 回答