views:

78

answers:

1

Hi,

I put a background in my view like this:


    UIImage *picture = [UIImage imageNamed:@"myImage.jpg"];
    self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:picture];

The problem is my picture is not big enough for the screen, so it repeat many times and its also not center in the View. How can I change that?

Thank you,

A: 

If you want to use a background image like this, then use a UIImageView, rather than the backgroundColor property of a standard view. In Interface Builder, add a UIImageView, size it to the same size as your view (adjust the struts and springs to match), give it your image, and make your view transparent.

Ben Gottlieb
I display image using my database so I can't give my UIImageView an image in IB, I have to give it programmatically.
ludo
Okay, no problem; still use a UIImageView, but load its image dynamically, just as you were doing with the backgroundColor
Ben Gottlieb
did I have to do that in ViewDidLoad? because I told you I have many elements made in IB like label, slider, textfield... and when I put the image dynamically like you said, some label and textview are cover by the UIImageView, I don't understand, becaud in the IB i'm sure that all the elements are in front of the UIImageView
ludo
Just make sure your image view is behind all of them by selecting it and then selecting "Send To Back" from the Layout menu.
Ben Gottlieb