I have a UIView
with a custom shape drawn in drawRect:
. The frame
property is set to:
{5.f, 6.f, 50.f, 50.f}
Now, I render the view in an Image Context, but it is ignoring the frame property of the UIView
, and always drawing the UIView
in the top left.
[_shapeView.layer renderInContext:UIGraphicsGetCurrentContext()];
I tried to change the frame
of the CALayer
, but nothing changed. Modifying the bounds
property made things worse. The only work around I found useful was:
CGRect frame = _shapeView.frame;
CGContextTranslateCTM(context, frame.origin.x, frame.origin.y);
[_shapeView.layer renderInContext:context];
But, this is impractical when I am dealing with many shapes, I want to just use the frame property.
bounds
instead. – KovnoCGContextDrawLayer
methods, which throw EXE_BAD_ACCESS when I try to use them.. I guess it's better to avoid those.. – Outreach