Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customizing the UIPopoverController view background and border color

Tags:

ios

ipad

popover

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!

like image 236
Mustafa Avatar asked May 12 '11 06:05

Mustafa


3 Answers

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.

like image 186
Ashok Avatar answered Nov 19 '22 10:11

Ashok


Now in iOS 5, popoverBackgroundViewClass is available.

like image 5
akaru Avatar answered Nov 19 '22 09:11

akaru


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.

like image 2
bdunagan Avatar answered Nov 19 '22 09:11

bdunagan