Creating UIImage with renderingMode in Swift

that would be the proper syntax:


(for Swift 3.x or Swift 4)

var image: UIImage? = UIImage(named:"myImage")?.withRenderingMode(.alwaysOriginal)

(for Swift 2.x)

var image: UIImage? = UIImage(named:"myImage.png").imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)

but you can use this 'shortcut' as well:

var image: UIImage? = UIImage(named:"myImage.png").imageWithRenderingMode(.AlwaysOriginal)