iphone - How to render UIView into a CGContext -
i wanted render uiview cgcontextref
-(void)methodname:(cgcontextref)ctx { uiview *someview = [[uiview alloc] init]; magicalfunction(ctx, someview); }
so, magicalfunction here supposed render uiview(may layer) current context.
how do that?
thanks in advance!
how renderincontext method of calayer?
-(void)methodname:(cgcontextref)ctx { uiview *someview = [[uiview alloc] init]; [someview.layer renderincontext:ctx]; }
edit: noted in comment, due difference in origins in 2 coordinate systems involved in process, layer rendered upside-down. compensate, need flip context vertically. technically done scale , translation transformation, can combined in single matrix transformation:
-(void)methodname:(cgcontextref)ctx { uiview *someview = [[uiview alloc] init]; cgaffinetransform verticalflip = cgaffinetransformmake(1, 0, 0, -1, 0, someview.frame.size.height); cgcontextconcatctm(ctx, verticalflip); [someview.layer renderincontext:ctx]; }
Comments
Post a Comment