First of all, I think I might be going about this the wrong way so bare with me.
I have a UIView where I draw a bunch of stuff using UIBezierPaths in the drawRect:. I need this drawing as a UIImage.
First problem: Before the drawRect: has actually done its job I don't know the size required for the UIView. So I init the view with an arbitrary size with the intention to crop it after. At the end of the drawRect: I know the bounds of the drawing though.
Second, this is what seems most horrible to me, I need to alloc&init my view, add it as a subview of a visible view. Exit the runloop and then I can take a screenshot by view.layer renderInContext:
So I'm thinking the drawRect: of a UIView is not the right place for me to be drawing stuff if I want a UIImage after. But if it isn't, what is? What's the better approach here?
I have a UIView where I draw a bunch of stuff using UIBezierPaths in the drawRect:. I need this drawing as a UIImage.
First problem: Before the drawRect: has actually done its job I don't know the size required for the UIView. So I init the view with an arbitrary size with the intention to crop it after. At the end of the drawRect: I know the bounds of the drawing though.
Second, this is what seems most horrible to me, I need to alloc&init my view, add it as a subview of a visible view. Exit the runloop and then I can take a screenshot by view.layer renderInContext:
So I'm thinking the drawRect: of a UIView is not the right place for me to be drawing stuff if I want a UIImage after. But if it isn't, what is? What's the better approach here?