Customizing the UIPopoverController view background and border color

谁说我不能喝 提交于 2019-12-20 12:28:15

问题


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!


回答1:


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.




回答2:


iOS 7 onwards, you can change backgroundColor of UIPopoverController which affects the navigation background color as well as arrows of popover.

@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.




回答3:


Now in iOS 5, popoverBackgroundViewClass is available.




回答4:


Check this cool link.....

For iOS5,

http://thinkvitamin.com/code/ios/customizing-the-design-of-uipopovercontroller/

Regards, Arun.




回答5:


From ios 5 onward you can do much just try this library https://github.com/ddebin/DDPopoverBackgroundView you can customise border tint color, bodrer width as well as arrow

look at the documentation




回答6:


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.




回答7:


here I developed a good solution for this trouble:

change color navigation controller in a popover

good luck!




回答8:


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.



来源:https://stackoverflow.com/questions/5974439/customizing-the-uipopovercontroller-view-background-and-border-color

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!