复制文字,链接,剪贴板的使用

//获取剪贴板

        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];

        //设置剪贴板内容

        pasteboard.string = [defaults objectForKey:@"shareURL"];

        if (pasteboard.string) {

            _alertView = [[AlertView alloc] initWithFrame:CGRectMake((UIScreen_width-(UIScreen_width/320)*150)/2, (UIScreen_width/320)*220, (UIScreen_width/320)*150, (UIScreen_width/320)*30)];

            [_alertView createAlertViewWithTitle:@"已复制到粘贴板" delayInSeconds:2 completion:^{

                [_alertView removeFromSuperview];

            }];

            [self.view addSubview:_alertView];

        } else {

            _alertView = [[AlertView alloc] initWithFrame:CGRectMake((UIScreen_width-(UIScreen_width/320)*150)/2, (UIScreen_width/320)*220, (UIScreen_width/320)*150, (UIScreen_width/320)*30)];

            [_alertView createAlertViewWithTitle:@"复制失败" delayInSeconds:2 completion:^{

                [_alertView removeFromSuperview];

            }];

            [self.view addSubview:_alertView];

        }

原文地址:https://www.cnblogs.com/OIMM/p/5096560.html