Swift

Swift 4: Convert Unix Timestamp to a nicely formatted Date & Time

I needed to convert a Unix Timestamp, which for some inexplicit reason was being returned as a String by an API I was using and this is the super foolish function I ended up with. I am not going to shame the API Provider for returning a timestamp as a String 😉 func createDateTime(timestamp: String) […]

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: func scaleImageWidth(sourceImage:UIImage, scaledToWidth: CGFloat) -> UIImage { let oldWidth = sourceImage.size.width let scaleFactor = scaledToWidth / oldWidth let newHeight = sourceImage.size.height * scaleFactor let newWidth = oldWidth * scaleFactor […]

Scroll to top