반응형
iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다.
class UIImagePickerViewController: UIViewController {
let imagePickerController = UIImagePickerController()
override func viewDidLoad() {
super.viewDidLoad()
imagePickerController.delegate = self
imagePickerController.sourceType = .photoLibrary
view.backgroundColor = .white
self.present(imagePickerController, animated: true)
}
}
extension UIImagePickerViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
self.dismiss(animated: true)
}
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
self.dismiss(animated: true)
}
}
반응형
'iOS > 코드조각' 카테고리의 다른 글
[iOS, Swift] ImageView ContentMode 특징 (Scale to Fill, Aspect Fit, Aspect Fill) (0) | 2022.08.21 |
---|---|
[iOS, Swift] UIImageView 원으로 만들기 (0) | 2022.08.21 |
[iOS, Swift] UIImage 그라데이션 그리기 (Gradient Image) (0) | 2022.08.21 |
[iOS, Swift] LocalNotification Foreground 알림 받기 (0) | 2022.08.21 |
[iOS, Swift] LocalNotification Badge 숫자 올리기 (0) | 2022.08.21 |