renderInContext flips the origin of colorWithPatternImage
ios
Solution
I managed to work around this by calling CGContextSetPatternPhase with a height of modf(viewHeight, patternHeight)
Problem
I have `UIView` with `backgroundColor` set with `colorWithPatternImage`. As expected, the background image is drawn starting at the top left corner. Problem appears when I'm doing `renderInContext` on that view: the background image is drawn starting at the bottom left corner. Everything else seems to render fine. Here's the source and destination images: Here is the code: ``` // 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(); ``` Is there a way to keep the image to tile in right direction, as in the `src` view?