Skip to content

Instantly share code, notes, and snippets.

@saoudrizwan
Created August 19, 2017 23:04
Show Gist options
  • Save saoudrizwan/c18911048422ccb6f53aad5ccd10e111 to your computer and use it in GitHub Desktop.
Save saoudrizwan/c18911048422ccb6f53aad5ccd10e111 to your computer and use it in GitHub Desktop.
// Add our responsive view to a super view
let responsiveView = ResponsiveView(frame: CGRect(x: 100, y: 300, width: 50, height: 50))
self.view.addSubview(responsiveView)
// make responsiveView self.view's super window's first responder
responsiveView.becomeFirstResponder()
// Set up the shared UIMenuController
let menu = UIMenuController.shared
menu.arrowDirection = .default // up, down, left, right
// Tell the menu controller the first responder's frame and its super view
menu.setTargetRect(responsiveView.frame, in: self.view)
// Animate the menu onto the super view
menu.setMenuVisible(true, animated: true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment