Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tiled Background Image: Can I do that easily with UIImageView?

I have a fullscreen background image that is tiled, i.e. it has to be reproduced a few times horizontally and vertically in order to make a big one. Like in the browsers on ugly home pages ;)

Is UIImageView my friend for this?

like image 389
Thanks Avatar asked Jul 14 '09 13:07

Thanks


People also ask

What is a tiled background image?

Tiled Background Images A tiled background image is a small size image that is designed so that it can repeat seamlessly both horizontally and vertically.

Which property controls how background images are tiled?

Description. The background-repeat property controls whether or not a background-image is repeated (tiled), and if it is repeated, the property defines along which of the specified axes (x, y, or both) the image is to be repeated.


2 Answers

If I understand your question correctly you can use colorWithPatternImage: on UIColor then set the background color on a UIView.

If you must use a UIImageView you can do the same but whatever image you place in the image view will draw in front of the tiled image.

like image 76
Bill Dudney Avatar answered Oct 01 '22 20:10

Bill Dudney


To get alpha to work with pattern image, make sure you have the following set:

view.backgroundColor = [UIColor colorWithPatternImage:aImage]; view.layer.opaque = NO; 
like image 41
Kyle Avatar answered Oct 01 '22 20:10

Kyle