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

冷暖自知 提交于 2019-12-01 02:15:08

问题


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.


回答1:


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.




回答2:


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.




回答3:


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




回答4:


  • You cannot remove the arrow or the border. If you do some kind of hack, as suggested by TomSwift, you risk crashes and refusal from apple when submitting your app for appStore.

  • You can implement your own custom popover like controller though, as suggested by Kevin. You can find an opensource project doing just that over here : https://github.com/werner77/WEPopover . Backgound and arrow can be remove from that one or set as transparent.



来源:https://stackoverflow.com/questions/4755786/how-to-remove-ipads-popover-arrow-and-its-frame-border

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