class UILabelCopy: UILabel {
override init(frame:CGRect) {
super.init(frame: frame);
self.attachTapHandler();
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func awakeFromNib() {
self.awakeFromNib();
self.attachTapHandler();
}
func attachTapHandler(){
self.userInteractionEnabled = true;
let touch : UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTap));
touch.numberOfTapsRequired = 2;
self.addGestureRecognizer(touch);
}
func handleTap(recognizer:UITapGestureRecognizer){
self.becomeFirstResponder();
let menuC : UIMenuController = UIMenuController();
menuC.setTargetRect(self.frame, inView: self.superview!);
menuC.setMenuVisible(true, animated: true);
}
Swift UIPasteboard 复制label上的文字
最新推荐文章于 2020-07-17 06:52:57 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)