views:

16

answers:

1

I have a UIScrollView that contains a subview that I want to fill with a texture.

- (void)drawRect:(CGRect)rect {

    CGImageRef image_to_tile_ret_ref = CGImageRetain(wood.CGImage);
    CGRect tile_rect;
    tile_rect.size = wood.size;

    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextBeginPath(context);
    CGContextMoveToPoint(context, 0, 0);
    CGContextDrawTiledImage(context, tile_rect, image_to_tile_ret_ref);
// Something here to make it fill a big area
    CGContextFillPath(context);

    CGImageRelease(image_to_tile_ret_ref);
}

This just seems to fill the visible area of the scroll view and when I scroll, the rest is white. How do I draw a rectangle beyond the bounds of the rect? Is that bad?

A: 

If you want to draw a background color in this is too much. UIScrollView can have a background color. That color can be created from a patter that is an image.

You can create a pattern color

UIColor * bgColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"imgname.png"]];
scrollView.backgroundColor = bgColor;
krzyspmac
great, thank you!
Michael Forrest