点击按钮,复制内容

    BGButton * copyButton =[BGButton buttonWithType:UIButtonTypeCustom];

    copyButton.backgroundColor= [UIColorclearColor];

    [copyButtonaddTarget:self action:@selector(copyClick) forControlEvents:UIControlEventTouchUpInside];

    [self.contentViewaddSubview:copyButton];



- (void)copyClick{

    UIPasteboard * pasteboard = [UIPasteboard generalPasteboard];

    pasteboard.string=self.leftThirdLabel.text;

    //设置HUDStyle

    [SVProgressHUD setDefaultStyle:(SVProgressHUDStyleDark)];

    if(pasteboard ==nil) {

        [SVProgressHUD showErrorWithStatus:BGLocaltring(@"Copy failed")];

    }else{

        [SVProgressHUD showSuccessWithStatus:BGLocaltring(@"Copy successfully")];

    }

    [SVProgressHUD dismissWithDelay:1.0];

}

你可能感兴趣的:(点击按钮,复制内容)