Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove iPad's Popover arrow and its frame border

Tags:

ipad

popover

Basically these are two questions:

  1. How to remove iPad's popover view's arrow?

  2. is there any way to remove popover's black border?

If not possible, can you suggest a way in iPad to display an UIView (popover) at the top of screen without arrow and border (might be light transparent border), please? thanks a lot.

And I don't think ModalView is a proper option, as it cannot be resized and cannot be dismissed by clicking outside modal view.

like image 801
Aragon Avatar asked Jan 21 '11 05:01

Aragon


3 Answers

AFIK there is no built-in way to specify "no arrow", or to have a popup sans borders.

This a hack, but it basically works. In the context of your view controller that is managed by the popup controller, during viewWillAppear:, get the popup window and remove the first layer, which is what renders the arrow and border:

- (void) viewWillAppear: (BOOL) animated
{
    [super viewWillAppear: animated];

    UIView* v = self.view.superview;
    NSLog( @"%@", NSStringFromClass( [v class]) ); // this should print UIView

    v = v.superview;
    NSLog( @"%@", NSStringFromClass( [v class]) ); // this should print UIPopoverView

    [[v.layer.sublayers objectAtIndex:0] removeFromSuperlayer];
}       

I suppose you could experiment with adding back your own layer that rendered the background/border the way you wanted to.

like image 171
TomSwift Avatar answered Jan 04 '23 04:01

TomSwift


How to remove iPad's popover view's arrow?

When calling -presentPopoverFromBarButtonItem:permittedArrowDirections:, pass 0 as the second parameter, rather than any of the constants. This isn't documented, but Apple is allowing apps in the App Store when using this setting.

like image 41
Dave Batton Avatar answered Jan 04 '23 03:01

Dave Batton


You cannot remove the chrome around the popover. Your best bet is to reimplement the idea of a popover, but using custom code.

like image 29
Lily Ballard Avatar answered Jan 04 '23 05:01

Lily Ballard