This is actually possible with UILabel, only you will need to do some subclasses.
The end result: when your user clicks on the label for a long time, he or she will see a copy of the ball.

Below are the steps to make a copy with a copy (as I recall):
- subclass of UILabel
- set userInteractionEnabled = YES
- override canBecomeFirstResponder and return true
- add UILongPressGestureRecognizer
- will be the first responder and representative of UIMenuController
Swift 3:
let menu = UIMenuController.shared if !menu.isMenuVisible { self.becomeFirstResponder() menu.setTargetRect(self.bounds, in: self) menu.setMenuVisible(true, animated: true) }
- override canPerformAction to allow copying
Swift 3:
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { return action == #selector(UIResponderStandardEditActions.copy(_:)) }
- override copy method, UIP Download text and hide UIMenuController
Swift 3:
let menu = UIMenuController.shared let labelText = self.text ?? self.attributedText?.string if let uLabelText = labelText { let clipBoard = UIPasteboard.general clipBoard.string = uText } menu.setMenuVisible(false, animated: true)
source share