views:

84

answers:

2

Hi,

i've got an UIImageView, now i want to repeat this image, that it always shows up again when scrolling left or right.

Little Example:

alt text

is this possible? it should feel like an infinite loop

A: 

The word "infinite" rules out a UISCrollView or a CATiledLayer, obviously.

I'd say the easiest way to achieve this is to initialize enough UIImageViews to completely fill your screen (or scroll area), plus one, and implement your own dragging/scrolling system and recycle the UIImageViews as they go off one side of the screen to reappear on the other side. Because all the UIImageViews are the same image you shouldn't ever have to worry about memory/cache management.

Echelon
A: 

If you don't care about performance, you can use a "pattern image":

UIView * backgroundView = [[[UIView alloc] initWithFrame:frame] autorelease];
backgroundView.backgroundColor = [UIColor colorWithPatternImage:repeatingImage];

I think it just draws it to the view's context, though, which means it can't be "infinite" and performance might be a bit slow.

tc.
can background color image be made zoomable?
choise