UIPopover without any arrows

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

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

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

    Try this one

    [popOverController presentPopoverFromRect:CGRectMake(0, 0, 30, 40) inView:popOverContentView permittedArrowDirections:0 animated:NO];
    
    0 讨论(0)
  • 2020-12-08 02:28

    In my case for swift developers

    popoverController.sourceView = self.view
    popoverController.sourceRect = self.view.bounds
    popoverController.backgroundColor = UIColor.brownColor()
    
    popoverController.permittedArrowDirections = UIPopoverArrowDirection.init(rawValue: 0)
    popoverController.sourceRect = CGRectMake(width/4, hieght/4, width/2, hieght/2);
    
    0 讨论(0)
  • 2020-12-08 02:29

    Yes it is possible just do:

     [self.popoverController presentPopoverFromBarButtonItem:anItem   
                                    permittedArrowDirections:0
                                                    animated:YES];
    

    The zero represent no direction.

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

    Nope, there is no UIPopoverArrowDirectionNone option, and UIPopoverArrowDirectionUnknown throws an exception i think if you try to use that to present.

    Instead of a popover controller, you can call presentModalViewController:animated: and set the controller you are presenting to have a modal presentation style of UIModalPresentationFormSheet or perhaps UIModalPresentationPageSheet. Those are more traditional popup screens than popovers are.

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

    A simple solution in SWIFT:

    popover!.permittedArrowDirections = nil
    
    0 讨论(0)
  • 2020-12-08 02:31

    For iPhone and swift 2.0 try this one

    Code to initiate popover

    initiatePopover(){
        let popoverContent = self.storyboard?.instantiateViewControllerWithIdentifier("XYZController") as! XYZController
        let nav = UINavigationController(rootViewController: popoverContent)
        nav.modalPresentationStyle = UIModalPresentationStyle.Popover
        let popover = nav.popoverPresentationController
        popoverContent.preferredContentSize = CGSizeMake(250 ,200)
        popover!.delegate = self
        popover!.sourceView = self.view
        popover!.sourceRect = CGRectMake(200,200,0,0)
        popover!.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
        self.presentViewController(nav, animated: true, completion: nil)
    }
    

    And add this to your ViewController

    func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
        return UIModalPresentationStyle.None
    }
    
    0 讨论(0)
提交回复
热议问题