xcode 弹出箭头与视图控制器背景颜色不同
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19501152/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Popover arrow not the same color as the viewcontroller background
提问by user2816600
The title says it all really. I have a view controller connected to a button as a popover. The view controller's background color is grey, but the color of the arrow pointing to the button is white. Any help would be much appreciated.
标题说明了一切。我有一个视图控制器作为弹出框连接到一个按钮。视图控制器的背景颜色为灰色,但指向按钮的箭头颜色为白色。任何帮助将非常感激。
回答by mahboudz
Here's how I get around it:
这是我解决它的方法:
popover = [[UIPopoverController alloc] initWithContentViewController:contentViewController];
popover.backgroundColor = contentViewController.view.backgroundColor;
This matches the popover to the color of the content's background.
这将弹出框与内容背景的颜色相匹配。
回答by NSGodMode
for ios 9.0 + (cpvc is your ViewController)
对于 ios 9.0 +(cpvc 是您的 ViewController)
cpvc.popoverPresentationController.backgroundColor = cpvc.view.backgroundColor;
回答by Xi Zhang
Are you using IOS7 sdk?
您使用的是 IOS7 sdk 吗?
maybe you can try:
也许你可以尝试:
[popover setBackgroundColor:[UIColor whiteColor]];
and make sure you set background color of the content view controller to white.
并确保将内容视图控制器的背景颜色设置为白色。
回答by AleyRobotics
swift 4.2
快速 4.2
navController?.popoverPresentationController?.backgroundColor = .black
回答by user3574848
I had the same problem in iOS7 (ugly white "arrow"). This seems to fix it for me. UIPopoverController does not support setBackgroundColor pre iOS7, thus the check.
我在 iOS7 中遇到了同样的问题(丑陋的白色“箭头”)。这似乎为我解决了。UIPopoverController 不支持 setBackgroundColor pre iOS7,因此检查。
if ([popoverController respondsToSelector:@selector(setBackgroundColor:)])
{
[popoverController setBackgroundColor:[UIColor clearColor]];
}