Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!!!

like image 628
Tanner Quigley Avatar asked May 19 '26 13:05

Tanner Quigley


1 Answers

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];
like image 196
polyclick Avatar answered May 22 '26 04:05

polyclick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!