When you drag an image from the desktop into the asset catalog in Xcode, you can access that image in a project using:
UIImage(named: "somePNG")
But how do you access that image using UIImage(contentsOfFile:)
?
if let path = Bundle.main.path(forResource: "somePNG", ofType: "png") {
someImageView.image = UIImage(contentsOfFile: path)
}
The above code doesn't work. The image in the file inspector is added to the target. What am I missing?