Created
August 28, 2019 07:57
-
-
Save HassanElDesouky/c4aa54e363f3da508a190bdfe5ea1fd7 to your computer and use it in GitHub Desktop.
This file contains 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
@IBAction func handleDone(_ sender: Any) { | |
let renderer = UIGraphicsImageRenderer(size: iconView.bounds.size) | |
let image = renderer.image { ctx in | |
iconView.drawHierarchy(in: iconView.bounds, afterScreenUpdates: true) | |
} | |
let finalIconDict: [String: UIImage] = ["finalIcon": image] | |
NotificationCenter.default.post(name: NSNotification.Name("finalIcon"), object: nil, userInfo: finalIconDict) | |
if list != nil { | |
let context = CoreDataManager.shared.persistentContainer.viewContext | |
let imageData = image.jpegData(compressionQuality: 0.8) | |
list?.setValue(imageData, forKey: "imageData") | |
do { | |
try context.save() | |
navigationController?.popViewController(animated: true) | |
} catch let err { | |
print(err) | |
} | |
} else { | |
navigationController?.popViewController(animated: true) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment