Tanner Quigley
Tanner Quigley

Reputation: 246

set background image dimensions IOS

I have an image bigger then a normal iPhone screen that I want to set as my background image but when I load the simulator I just see part of the image. Here is how I assigned the image:

UIImage *background = [UIImage imageNamed:@"background.png"];
[self.view setBackgroundColor:[UIColor colorWithPatternImage:background]];

how can I set the background image to something like self.view.bounds? If I was to use a UIImageView how do I ensure that it is in the background!!!

Upvotes: 3

Views: 3049

Answers (2)

polyclick
polyclick

Reputation: 2703

Make a UIImageView, give the UIImage to the UIImageView and add the UIImageView as a child to the view. Like so:

UIImageView *backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"name.png"]];
[backgroundView setFrame:CGRectMake(0, 0, 320, 480)];
[self.view insertSubView:backgroundView atIndex:0];
[backgroundView release];

Upvotes: 1

frankWhite
frankWhite

Reputation: 1542

Set uiimageview frame - this is limitations for display.

Use

 background.frame = CGRectMake (0,0, 320, 480); // as example - full screen,

also like in post above add addSubview and release code.

If you used frame - coordinates calculate from your superview - in that case - from self.view (simulator display). If you used bounds, coordinates calculate relatively to yours uiimageview (not self.view)

Upvotes: 0

Related Questions