我UIView用backgroundColor镶有colorWithPatternImage.正如预期的那样,背景图像绘制起始于顶部左上角.
当我这样做会出现问题renderInContext上的看法:背景图像绘制起始于底部左下角.其他一切似乎都很好.
这是源图像和目标图像:

这是代码:
// here is the layer to be rendered into an image
UIView *src = [[UIView alloc] initWithFrame:(CGRect){{0, 0}, {100, 100}}];
src.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];
[self.view addSubview:src];
// here we'll display the image
UIImageView *dest = [[UIImageView alloc] initWithFrame:(CGRect){{110, 0}, src.bounds.size}];
[self.view addSubview:dest];
// render `src` to an image in `dest`
UIGraphicsBeginImageContext(src.bounds.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[src.layer renderInContext:context];
dest.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)
有没有办法让图像在正确的方向上保持平铺,就像在src …
ios ×1