I Wanted to render a UIView into a CGContextRef
-(void)methodName:(CGContextRef)ctx {
UIView *someView = [[UIView alloc] init];
MagicalFunction(ctx, someView);
}
So, the MagicalFunction here is supposed to render the UIView(may be its layer) into current context.
How do I do that?
Thanks in advance!
How about the renderInContext method of CALayer?
EDIT: As noted in the comment, due to a difference in origins in the two coordinate systems involved in the process, the layer will be rendered upside-down. To compensate, you just need to flip the context vertically. This is technically done with a scale and translation transformation, which can be combined in a single matrix transformation: