Reputation: 59
I've literally piled through hundreds go searches on google :(. I can't seem to figure out what I'm doing wrong when I create an image in photoshop (960 x 600, -40 for the status bar). The image comes out to this:
When it should look like this:
(note this is not the actually size, crappy thumbnail version :P. The size is as stated above)
This is my code:
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"MenuBkground.png"]];
Am I doing something wrong when I make the image? Is it in the code? Any ideas?
Upvotes: 1
Views: 402
Reputation: 5936
Another way if your using interface builder,
Drag an image view
to your viewController.
Assign that as MenuBkground.png
in the inspector (first drop down box)
Upvotes: 2
Reputation: 6229
You're using colorWithPatternImage
which basically means what it says. The image will repeat itself if the space is not entirely consumed by the image. If you want to have a true background image you should create the image as a subview.
UIImage* image = [UIImage imageNamed:@"MenuBKground.png"];
UIImageView* background = [[UIImageView alloc]initWithImage: image];
[self.view addSubview: background];
Upvotes: 3