しめ鯖日記

swift, iPhoneアプリ開発, ruby on rails等のTipsや入門記事書いてます

Swiftでクリップボードへコピーする

UIPasteboardを利用します。

let board = UIPasteboard.generalPasteboard()
board.setValue("Text", forPasteboardType: "public.text")

iOS上で貼り付けをする事ができました。

f:id:llcc:20151208000107p:plain

クリップボードの値の取得は下の通りです。

let board = UIPasteboard.generalPasteboard()
board.valueForPasteboardType("public.text")