在 iOS 中,若要把文字複製到系統剪貼板,只需取得 UIPasteboard 的通用剪貼板物件,再設定其 string 屬性。
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; pasteboard.string = @"要複製的內容";
完成後,使用者就能在其他 App 或輸入框中貼上這段文字。若需要保存圖片或自訂資料,也可改用 UIPasteboard 的圖片或 item 系列 API。