This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ImagePicker.swift | |
| // ViewAndVC | |
| // | |
| // Created by Ryan J. W. Kim on 2021/10/29. | |
| // | |
| import SwiftUI | |
| struct ImagePicker: UIViewControllerRepresentable { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ImagePickerView.swift | |
| // ViewAndVC | |
| // | |
| // Created by Ryan J. W. Kim on 2021/10/29. | |
| // | |
| import SwiftUI | |
| // MARK: - ImageSave class | |
| class ImageSaver: NSObject { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func loadImage() { | |
| guard let inputImage = inputImage else { return } | |
| image = Image(uiImage: inputImage) | |
| let imageSaver = ImageSaver() | |
| imageSaver.writeToPhotoAlbum(image: inputImage) | |
| } //: loadImage func |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // MARK: - ImageSave class | |
| class ImageSaver: NSObject { | |
| func writeToPhotoAlbum(image: UIImage) { | |
| UIImageWriteToSavedPhotosAlbum(image, self, #selector(saveError), nil) | |
| } | |
| @objc func saveError(_ image: UIImage, didFinishSavingWithError error: Error?, contextInfo: UnsafeRawPointer) { | |
| print("Save finished!") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func loadImage() { | |
| guard let inputImage = inputImage else { return } | |
| image = Image(uiImage: inputImage) | |
| UIImageWriteToSavedPhotosAlbum(inputImage, nil, nil, nil) | |
| } //: loadImage func |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct ContentView: View { | |
| // MARK: - Properties | |
| @State private var image: Image? | |
| @State private var showingImagePicker = false | |
| @State private var inputImage: UIImage? | |
| // MARK: - Body | |
| var body: some View { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct ImagePicker: UIViewControllerRepresentable { | |
| class Coordinator: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate { | |
| var parent: ImagePicker | |
| init(_ parent: ImagePicker) { | |
| self.parent = parent | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct ContentView: View { | |
| // MARK: - Properties | |
| @State private var image: Image? | |
| @State private var showingImagePicker = false | |
| // MARK: - Body | |
| var body: some View { | |
| VStack { | |
| image? | |
| .resizable() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct ImagePicker: UIViewControllerRepresentable { | |
| func makeUIViewController(context: Context) -> UIImagePickerController { | |
| let picker = UIImagePickerController() | |
| return picker | |
| } | |
| func updateUIViewController(_ uiViewController: UIImagePickerController, context: Context) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import CoreImage | |
| import CoreImage.CIFilterBuiltins | |
| import SwiftUI | |
| struct CoreImageIntegration: View { | |
| // MARK: - Properties | |
| @State private var image: Image? | |