0

我有一个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);
}

这似乎只是填充了滚动视图的可见区域,当我滚动时,其余部分是白色的。如何绘制超出矩形边界的矩形?那不好吗?

4

1 回答 1

0

如果你想在这个中画一个背景颜色就太多了。UIScrollView 可以有背景颜色。可以从作为图像的模式创建该颜色。

您可以创建图案颜色

UIColor * bgColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"imgname.png"]];
scrollView.backgroundColor = bgColor;
于 2010-07-09T15:11:04.057 回答