iOS Swift/개발 이모저모5 [사진]촬영 후 바로 아이폰 앨범에 저장하기 func saveImage(image : UIImage) { let data = image.jpegData(compressionQuality: 0.9)! PHPhotoLibrary.requestAuthorization { [unowned self] status in if status == .authorized { PHPhotoLibrary.shared().performChanges({ let creationRequest = PHAssetCreationRequest.forAsset() creationRequest.addResource(with: .photo, data: data, options: nil) }, completionHandler: { success, error in if success { pr.. 2022. 12. 27. [권한]앨범 접근 권한 여부 확인하고 바로 후처리 @objc func pickImage(){ if albumAccess(){ chooseAlbumMethod() } else { let status = PHPhotoLibrary.authorizationStatus() if status == .notDetermined { PHPhotoLibrary.requestAuthorization{status in switch status { case .authorized, .limited : print("album access allowed") DispatchQueue.main.asyncAfter(deadline: .now() + 0.5){ self.chooseAlbumMethod() } case .denied, .restricted : print("album acc.. 2022. 12. 22. [권한]아이폰 앨범 접근 권한 확인하기 func albumAccess() -> Bool{ let status = PHPhotoLibrary.authorizationStatus() PHPhotoLibrary.requestAuthorization{status in switch status { case .authorized, .limited : print("album access allowed") case .denied, .restricted : print("album access not allowed") case .notDetermined : print("album access not determined") @unknown default: print("albmum access default") } } if status == PHAuthorizat.. 2022. 12. 21. [사진]UIImagePickerController로 아이폰 기기 앨범의 이미지 선택하기 let imagePickerController = UIImagePickerController() func changeProfileImage() { let ac = UIAlertController(title: "PROFILE_CHANGE_TITLE".localized(), message: "PROFILE_CHANGE_INST".localized(), preferredStyle: .actionSheet) ac.addAction(UIAlertAction(title:"PROFILE_CHANGE_PHOTO".localized(), style: .default, handler: { action in print("camera clicked") })) ac.addAction(UIAlertAction(title:"PRO.. 2022. 12. 21. [사진]Mantis Library 활용하여 이미지 크롭해보기 extension MyPageViewController : CropViewControllerDelegate { func cropViewControllerDidCrop(_ cropViewController: CropViewController, cropped: UIImage, transformation: Transformation) { print("successfully cropped") print("cropped is \(cropped)") self.croppedProfileImage = cropped cropViewController.dismiss(animated: true, completion: nil) } func cropViewControllerDidCancel(_ cropViewController.. 2022. 12. 21. 이전 1 다음