Skip to content

Instantly share code, notes, and snippets.

@DonMag
Created January 10, 2017 19:27
Show Gist options
  • Select an option

  • Save DonMag/049d45227cd8e8d454637416ffa5de27 to your computer and use it in GitHub Desktop.

Select an option

Save DonMag/049d45227cd8e8d454637416ffa5de27 to your computer and use it in GitHub Desktop.
@IBAction func buttonCalendar(sender: AnyObject) {
guard let bbItem = sender as? UIBarButtonItem else { return }
// instantiate the popover menu view controller
let vc = PopMenuTableViewController()
// set the desired size and background color
vc.preferredContentSize = CGSize(width: 140, height: 180)
vc.view.backgroundColor = UIColor.lightGrayColor()
// set the custom PopoverMenuDelegate to self
vc.menuDelegate = self
// tell the popover which item is currently selected
vc.checkMarkIndex = currentSelection
// set the popover "styling"
vc.modalPresentationStyle = .Popover
vc.popoverPresentationController?.backgroundColor = UIColor.lightGrayColor()
// tell it what object to use as the popover "pointy thingy" reference
vc.popoverPresentationController?.barButtonItem = bbItem
// set the UIPopoverPresentationControllerDelegate to self
vc.popoverPresentationController?.delegate = self
// show the popover menu
presentViewController(vc, animated: true, completion: nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment