MilkBottle
MilkBottle

Reputation: 4332

Set image background for view with 3 images sizes

I did the following:

1) copy 3 images size of wall paper into supporting file folder with standard naming

WP.png, [email protected], [email protected]

override func viewDidLoad() {
    super.viewDidLoad()
    self.view.backgroundColor = UIColor(patternImage: UIImage(named: "WP"))
}

The problems:

1). There are 3 images overlap one another

2) if I did as below, the same problem as (1)

self.view.backgroundColor = UIColor(patternImage: UIImage(named: "WP@2x"))

or

self.view.backgroundColor = UIColor(patternImage: UIImage(named: "[email protected]"))

How to make sure the wp size for the right screen size?

TIA.

Upvotes: 0

Views: 122

Answers (1)

Nick Groeneveld
Nick Groeneveld

Reputation: 903

Make sure you use the name you provide here (see arrow in image). XCode will add the right image.

enter image description here

You can also specify the size by hand if you must. This goes as follows:

self.yourImageVariableName.size.width = self.frame.size.width
self.yourImageVariableName.size.height = self.frame.size.height

Upvotes: 0

Related Questions