Sunday, January 25, 2026
HomeiOS Developmentios - How do I create popover menu?

ios – How do I create popover menu?


I wish to create a settings menu like in Apple Books app. I feel one of the simplest ways to do that job is to make use of a PopoverContentController with a StackView inside. However I’ve a couple of issues.

first drawback:

If I take advantage of the default PopoverContentController, I see the arrow, however there isn’t a arrow in my picture. I take advantage of this line to take away the course of the arrow:

popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirection.init(rawValue: 0)

However on this case I do not see the PopoverContentController easy down open animation as a result of I eliminated the arrow. How one can repair it?

second drawback:

To get the menu like within the instance picture, I must take away the background to see the space between the weather. I am making an attempt to make use of this code

popoverPresentationController.backgroundColor = .celar

or this:

view.backgroundColor = .celar

This does not assist me. I see blur background. How one can repair it?

full code:

 let popoverContentController = MenuVC()
 popoverContentController.modalPresentationStyle = .popover

 let popoverPresentationController = popoverContentController.popoverPresentationController
 popoverPresentationController?.permittedArrowDirections = .up
 popoverPresentationController?.sourceView = self.view
 popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.init(rawValue: 0)
        
 popoverContentController.preferredContentSize = CGSize(width: 250, peak: 250)
 popoverPresentationController?.delegate = self
        
 popoverPresentationController?.sourceRect = CGRect(
      x: self.rightStackView.body.origin.x + self.rightStackView.arrangedSubviews[0].body.origin.x + (rightBarButtonWidth/2),
      y: self.rightStackView.body.origin.y + self.rightStackView.arrangedSubviews[0].body.origin.y + (rightBarButtonHeight),
      width: 0,
      peak: 0)
        
 current(popoverContentController, animated: true, completion: nil)

enter image description here

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments