UIPopover without any arrows

前端 未结 17 1108
说谎
说谎 2020-12-08 02:15

Is it possible to present a popover without any sort of arrows pointing somewhere?

相关标签:
17条回答
  • 2020-12-08 02:20

    Swift3, this code work for me

    popover.permittedArrowDirections = .init(rawValue: 0)
    
    0 讨论(0)
  • 2020-12-08 02:20

    Try this , it works for me.

    [self.popoverViewController presentPopoverFromRect:rect inView:self.view  permittedArrowDirections:0 animated:YES];
    
    0 讨论(0)
  • 2020-12-08 02:21

    I use popover to show menu depending on touch coordinate. In this case popover uses maximum height of self.view

    CGRect popeverFrame = CGRectMake(touchPoint.x, touchPoint.y, 0, 0);
    [self.popover presentPopoverFromRect:popeverFrame
                                  inView:self.view
                permittedArrowDirections:UIPopoverArrowDirectionAny
                                animated:YES];
    

    But when I use 0-direction. Popover rectangle doesn't set it height to maximum and can only be set by appropriate property.

    CGRect popeverFrame = CGRectMake(touchPoint.x, touchPoint.y, 0, 0);
    [self.popover presentPopoverFromRect:popeverFrame
                                  inView:self.view
                permittedArrowDirections:UIPopoverArrowDirectionAny
                                animated:YES];
    

    Hope this will help: Help with UIPopOverController size

    0 讨论(0)
  • 2020-12-08 02:21

    To make a pop over direction none and make it to appear in center of the view controller :

    let PopSrnVar = popoverPresentationController
    let ConRctVar = view.frame
    PopSrnVar!.sourceRect = CGRectMake(ConRctVar.width/4, ConRctVar.height/4, ConRctVar.width/2, ConRctVar.height/2)
    // To make arrows as none
    PopSrnVar!.permittedArrowDirections = UIPopoverArrowDirection()
    
    0 讨论(0)
  • 2020-12-08 02:26

    For Swift 2.0 and iOS9 the solution is:

    popoverViewController?.permittedArrowDirections = UIPopoverArrowDirection()
    
    0 讨论(0)
  • 2020-12-08 02:26

    In Swift, you can simply do:

    popoverPresentationController.permittedArrowDirections = []
    

    Since in another configuration you could have used:

    popoverPresentationController.permittedArrowDirections = [.up, .down]
    
    0 讨论(0)
提交回复
热议问题