반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Java
- Observable
- 웹뷰
- LazyHStack
- Realtime Database
- Firebase
- RxSwift
- ios
- swipe
- Apple
- remote config
- Alamofire
- gcd
- 다크모드
- 라이트모드
- github
- SwiftUI
- UIButton
- dictionary
- SwiftLint
- NavigationLink
- Android
- Swift
- string
- 문자열
- UITabBarController
- UIScrollView
- subscript
- WebView
- autolayout
Archives
- Today
- Total
점진적 과부하 개발 블로그
Swift UIPasteboard Class // 복사 버튼 만들기 본문
반응형
Swift UIPasteboard Class // 복사 버튼 만들기
Apple Developer Documentation
developer.apple.com
UIPasteBoard Class
- 사용자가 앱 내에서 한 위치에서 다른 위치로, 그리고 앱에서 다른 앱으로 데이터를 공유할 수 있도록 도와주는 개체입니다.
선언
class UIPasteboard : NSObject
예제
- Button(coptButton)과 Label(textLabel을 하나씩 만들어 주겠습니다.
- copyButton 메서드를 선언해주고 UIPasteboard에 textLabel에 text값을 대입하겠습니다.
- copyButton을 클릭하면 textLabel의 text값이 복사가 됩니다.
import UIKit
class ViewController: UIViewController {
@IBAction func copyButton(_ sender: UIButton) {
UIPasteboard.general.string = textLabel.text
}
@IBOutlet weak var textLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
}
}
반응형
'Swift' 카테고리의 다른 글
Swift SFSafariViewController 알아보기 (0) | 2022.08.26 |
---|---|
Swift 특정 문자열 제거 및 치환 (0) | 2022.08.22 |
Swift 메모리 안전 정리 (0) | 2022.08.08 |
SwiftUI ProgressView (0) | 2022.08.04 |
Swift Localization / 다국어 처리 (0) | 2022.08.02 |