Skip to content

Instantly share code, notes, and snippets.

@ArchieR7
Last active October 5, 2017 11:30
Show Gist options
  • Save ArchieR7/0ac0d77ee861cfe1e1b51e27765f3f82 to your computer and use it in GitHub Desktop.
Save ArchieR7/0ac0d77ee861cfe1e1b51e27765f3f82 to your computer and use it in GitHub Desktop.
private func scaleMapImage(_ image: UIImage?, size: CGSize) -> UIImage? {
        guard let image = image else {
            return nil
        }
        UIGraphicsBeginImageContext(CGSize(width: size.width, height: size.height))
        image.draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height))
        let newImage = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return newImage
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment