# ios 复制字符串到剪贴板

1,082 阅读1分钟

标签(空格分隔): ios 剪切板


1.文本UILable设置可以交互 2.添加长按手势

[jobInfoText addGestureRecognizer:longPress];```

3.响应`长按手势`

```- (void)copyText:(UILongPressGestureRecognizer *)gesture
{
    if (gesture.state ==UIGestureRecognizerStateBegan) 
  {
        UIPasteboard *pasteboard = [UIPasteboardgeneralPasteboard];
        [pasteboard setString:self.jobInfoText.text];
    }
}```