代码改变世界

ios - 剪切板

2017-05-18 14:51  菜鸟Alex  阅读(273)  评论(0编辑  收藏  举报

长按

//例如长按一个按钮
UILongPressGestureRecognizer * lonPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(paste:)];
//获取按钮的标题title
-(void)paste:(UILongPressGestureRecognizer *)ges{
    //获取系统剪切板
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    UBButton * btn = (UBButton *)ges.view;
    pasteboard.string = btn.currentTitle;
    //[self showHint:@"已经复制到剪切板"]; 提示用户已经复制
}