How to draw a big background inside a UIScrollView?
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();
开发者_JAVA百科 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?
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;
精彩评论