UIScrollView with pattern as background

here is the problem i am facing: i am creating a UIScrollView which will have a template image to fill the background . That is, I need a background to scroll using UIScrollView. A good example of this is the Game Center app on the iPad. The background will scroll smoothly by scrolling.

I currently have two ways to implement this effect, but none of them have shown good performance . I tried this first

self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:kRLCastViewBGUnit]];

but unfortunately the scroll performance was very poor and took up too much memory.

Then I tried using CGContextDrawTiledImage in drawRect as follows:

- (void)drawRect:(CGRect)rect
{
    CGContextRef currentContext = UIGraphicsGetCurrentContext();

    CGContextTranslateCTM(currentContext, 0, rect.size.height);
    CGContextScaleCTM(currentContext, 1.0, -1.0);

    CGContextClipToRect(currentContext, rect);
    CGRect centerTileRect = CenterTileRect;
    CGContextDrawTiledImage(currentContext, centerTileRect, [ResourceProvider backgroundTileImageRef]);

}

iPad. , , - , Game Center , . - UIScrollView? !

+3
1

UITableView. cell.backgroundView.

UIImageView *backgroundView = [[UIImageView alloc] initWithFrame:CGRectMake:(0.0,0.0,320.0, height)];
backgroundView.image = [UIImage imageNamed:@"Shelf.jpeg"];
cell.backgroundView = backgroundView;

UIScrollView, , scrollView, colorWithPatternImage: tiled.

backgroundColor UIScrollView.

[scrollView setContentSize:CGSizeMake(320.0, 1000.0)];
[scrollView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"cellImage.png"]]];
0

All Articles