Swift 4: scale image to width

For an app that I was writing I needed an easy function to scale an image to a specific width, the function below will accomplish this:

I can guarantee you that I did not come up with that function, but I can no longer recall, where I got it from. Most likely place is Stack Overflow 🙂

You Might Also Like