ios 自定义 UIPopoverController 视图背景和边框颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5974439/
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
Customizing the UIPopoverController view background and border color
提问by Mustafa
Is it possible to change the border color, navigation bar style/color, and arrow style/color of a pop over view? If so, how? If some sample code is available, then that'll be great!
是否可以更改弹出视图的边框颜色、导航栏样式/颜色和箭头样式/颜色?如果是这样,如何?如果有一些示例代码可用,那就太好了!
采纳答案by bdunagan
Unfortunately, UIPopoverController
is not customizable like that. You can't change the border color, navigation bar style/color, or arrow style/color: How to customize / style a UIPopoverController.
不幸的是,UIPopoverController
不能像那样定制。您不能更改边框颜色、导航栏样式/颜色或箭头样式/颜色:如何自定义/设置 UIPopoverController 的样式。
回答by Ashok
iOS 7 onwards, you can change backgroundColor
of UIPopoverController
which affects the navigation background color as well as arrows of popover.
iOS的7起,你可以改变backgroundColor
的UIPopoverController
影响导航的背景颜色以及酥料饼的箭头。
@property (nonatomic, copy) UIColor *backgroundColor NS_AVAILABLE_IOS(7_0);
Usage example:
用法示例:
if ([self.popoverVC respondsToSelector:@selector(setBackgroundColor:)]) { // Check to avoid app crash prior to iOS 7
self.popoverVC.backgroundColor = [UIColor greenColor];
}
Note- As of now (iOS 7.0.3), in some cases (like set color using colorWithPatternImage:), the simulator doesn't honor the color but on device it works fine.
注意- 截至目前(iOS 7.0.3),在某些情况下(例如使用 colorWithPatternImage: 设置颜色),模拟器不支持颜色,但在设备上它工作正常。
回答by akaru
Now in iOS 5, popoverBackgroundViewClass is available.
现在在 iOS 5 中,popoverBackgroundViewClass 可用。
回答by Arun
Check this cool link.....
检查这个很酷的链接.....
For iOS5,
对于iOS5,
http://thinkvitamin.com/code/ios/customizing-the-design-of-uipopovercontroller/
http://thinkvitamin.com/code/ios/customizing-the-design-of-uipopovercontroller/
Regards, Arun.
问候,阿伦。
回答by Kshitiz Ghimire
From ios 5 onward you can do much just try this library https://github.com/ddebin/DDPopoverBackgroundViewyou can customise border tint color, bodrer width as well as arrow
从 ios 5 开始,您可以做很多事情,只需尝试这个库https://github.com/ddebin/DDPopoverBackgroundView您可以自定义边框色调颜色、边框宽度以及箭头
look at the documentation
查看文档
回答by mjisrawi
The navigation bar and tool bar inside a popover are just a standard UINavigationBar and UIToolBar, I've had success in changing their appearance just as you would with a normal nav bar or tool bar. The border however is not easily customizable.
弹出框内的导航栏和工具栏只是一个标准的 UINavigationBar 和 UIToolBar,我已经成功地改变了它们的外观,就像使用普通导航栏或工具栏一样。然而,边框不容易定制。
回答by TurboManolo
here I developed a good solution for this trouble:
在这里,我为这个麻烦开发了一个很好的解决方案:
change color navigation controller in a popover
good luck!
祝你好运!
回答by vangoz
I try to trick it by customizing the viewcontroller inside the popover and then hiding the popover border using this code
我尝试通过自定义弹出框内的视图控制器然后使用此代码隐藏弹出框边框来欺骗它
UIView * border = [[insideViewController.view.superview.superview.superview subviews] objectAtIndex:0];
border.hidden = YES;
The app is actually still in development so I'm hoping other people will comment on this solution.
该应用程序实际上仍在开发中,所以我希望其他人对此解决方案发表评论。