Skip to content
A custom PopOverView looks like UIMenuController works on iPhone.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Demo
.gitignore
LICENSE
README.md
popOver.png

README.md

MenuPopOverView

MenuPopOverView been rewrite in swift. It looks like UIMenuController but can popover from anyview you want.

Install

Carthage:

github "camelcc/MenuPopOverView"

Example

class ViewController: UIViewController {
    var menuPopOverView: MenuPopOverView? = nil

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        self.view.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(tapped(tap:))))
    }

    override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
        super.viewWillTransition(to: size, with: coordinator)
        menuPopOverView?.dismiss(false)
    }

    @objc private func tapped(tap: UITapGestureRecognizer) {
        let tapLocation = tap.location(in: self.view)
        if menuPopOverView == nil {
            menuPopOverView = MenuPopOverView()
        }
        menuPopOverView?.delegate = self
        menuPopOverView?.present(at: CGRect(x: tapLocation.x, y: tapLocation.y, width: 0, height: 0),
                                in: self.view,
                                with: ["Test1", "TestAAAAAAA", "t", "example", "loooooooooooooooongbutton"])
    }
}

extension ViewController: MenuPopOverViewDelegate {
    func didSelect(view: MenuPopOverView, at index: Int) {
        print("didSelect at \(index)")
    }

    func didDismiss(view: MenuPopOverView) {
        print("didDismiss")
        menuPopOverView = nil
    }
}

popover

License

WTFPL

Support me

Buy me a coffee

You can’t perform that action at this time.