How to load specific image from assets with Swift

Ghost picture Ghost · Mar 30, 2015 · Viewed 99.4k times · Source

I'm new to Swift and I want to load a special image from assets. For example I have:

image 1 for iphone 4s = [email protected]
image 2 for iphone 5/5s = [email protected]
image 3 for iphone 6s = [email protected]

and I want to load for iphone 6 a specific image like

self.GSquare = SKSpriteNode(imageNamed: "./Images.xcassets/[email protected]")

Is it possible?

Answer

Azat picture Azat · Mar 30, 2015

You cannot load images directly with @2x or @3x, system selects appropriate image automatically, just specify the name using UIImage:

UIImage(named: "green-square-Retina")