I\'ve got some code that resizes an image so I can get a scaled chunk of the center of the image - I use this to take a UIImage and return a small, square repre
UIImage
Below code snippet might help.
import UIKit extension UIImage { func cropImage(toRect rect: CGRect) -> UIImage? { if let imageRef = self.cgImage?.cropping(to: rect) { return UIImage(cgImage: imageRef) } return nil } }