[TIL] 2021.03.06

์Šน์•„ยท2021๋…„ 3์›” 6์ผ
0

[TIL] iOS WishList์•ฑ ๊ฐœ๋ฐœ ๐Ÿผ

๋ชฉ๋ก ๋ณด๊ธฐ
23/27

๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป ์˜ค๋Š˜ ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ

Image Edit(Crop, Rotation ๋“ฑ) Library Mantis ์‚ฌ์šฉ ( Mantis, ์ฐธ๊ณ  ์‚ฌ์ดํŠธ)

  1. Podfile์— ์ถ”๊ฐ€
pod 'Mantis', '~> 1.4.13'
  1. pod install ํ•ด์ฃผ๊ธฐ
  2. import Mantis ์ถ”๊ฐ€
  3. CropViewController ๋„์šฐ๊ธฐ
let cropViewController = Mantis.cropViewController(image: ํ•ด๋‹น ์ด๋ฏธ์ง€ (UIImage))
cropViewController.delegate = self
cropViewController.modalPresentationStyle = .fullScreen
self.present(cropViewController, animated: true, completion: nil)
  1. ํ•จ์ˆ˜ ๊ตฌํ˜„
  • cropViewControllerDidCrop() : Done ๋ฒ„ํŠผ ๋ˆŒ๋ €์„ ๋•Œ ์‹คํ–‰
  • cropViewControllerDidCancel() : Cancel ๋ฒ„ํŠผ ๋ˆŒ๋ €์„ ๋•Œ ์‹คํ–‰
extension EditImageViewController: CropViewControllerDelegate{
    func cropViewControllerDidCrop(_ cropViewController: CropViewController, cropped: UIImage, transformation: Transformation) {
        photoViewModel.setPhoto(currentPage, cropped)
        imageView.image = photoViewModel.photos[currentPage]
        dismiss(animated: true, completion: nil)
    }
    
    func cropViewControllerDidCancel(_ cropViewController: CropViewController, original: UIImage) {
        dismiss(animated: true, completion: nil)
    }
}

โœ๐Ÿป ์˜ค๋Š˜์€...

crop์„ ๋„๋Œ€์ฒด ๋‚ด๊ฐ€ ์–ด๋–ป๊ฒŒ ํ•ด์•ผ๋˜๋‚˜ ๊ณ ๋ฏผํ–ˆ๋Š”๋ฐ ์˜คํ”ˆ์†Œ์Šค๊ฐ€ ์žˆ์—ˆ๋‹ค !!! Crop ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ํšŒ์ „, ๊ธฐ์šธ๊ธฐ๊นŒ์ง€ ์„ค์ •์ด ๊ฐ€๋Šฅํ•˜๋‹ค. ์ด๋ฏธ์ง€ ํŽธ์ง‘ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ Mantis ์ถ”์ฒœํ•ฉ๋‹ˆ๋‹ค ๐Ÿ‘๐Ÿป ๐Ÿ˜ญ

0๊ฐœ์˜ ๋Œ“๊ธ€