I'm trying to set up a background image for my app, but the image is tiling. How do I prevent this? I want my image to fit to the background.
In CSS I would set NO-REPEAT
; is there something like that?
I have tried this code:
-(IBAction)btnAddBackground
{
self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"image.jpg"]];
}
The documentation for UIView
makes a couple of suggestions for this:
- Image-based backgrounds - For views that display relatively static content, consider using a
UIImageView
object with gesture recognizers instead of subclassing and drawing the image yourself. Alternatively, you can also use a genericUIView
object and assign your image as the content of the view’sCALayer
object.