Iphone 如何在UIScrollView中绘制大背景?
我有一个Iphone 如何在UIScrollView中绘制大背景?,iphone,quartz-2d,Iphone,Quartz 2d,我有一个UIScrollView,其中包含一个子视图,我想用纹理填充它 - (void)drawRect:(CGRect)rect { CGImageRef image_to_tile_ret_ref = CGImageRetain(wood.CGImage); CGRect tile_rect; tile_rect.size = wood.size; CGContextRef context = UIGraphicsGetCurrentContext();
UIScrollView
,其中包含一个子视图,我想用纹理填充它
- (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);
}
这似乎只是填充了滚动视图的可见区域,当我滚动时,其余部分是白色的。如何在矩形的边界之外绘制矩形?那么糟糕吗 如果您想在中绘制背景色,这太多了。UIScrollView可以有背景色。该颜色可以从作为图像的图案创建 可以创建图案颜色
UIColor * bgColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"imgname.png"]];
scrollView.backgroundColor = bgColor;