How do I get CGContextRef object while in drawRect(CGRect rect)

I’m using CoreGraphics.CGContextSetLineWidth(context, 3) ,All these functions need a CGContextRef object. But I don’t know how to get this object.

In IOS, the function is UIGraphicsGetCurrentContext(), but I don’t see it in moe.

I can see UIGraphicsRenderContext.CGContext() return this object, but how to get? alloc? init ? while runing , it dosn’t work and Error invalid context 0x0.

Dear @lubo,

All of the methods of graphics worked successfully and i test all method.
First check objective-c code then try it on moe.
And for parameters you need to separate some methods name.
In this case I think you’re answer is :
UIGraphics.GetCurrentContext()
I haven’t access to my pc right now test it your self.

Regards,
Saeed.

Thanks for reply, but there is no such class in moe. I think moe lack of JavaDoc, that we totally have no idea which class to use. Only some document with some samples.

Hi!

These method can be found in the UIKit class:

CGContextRef cgContextRef = UIKit.UIGraphicsGetCurrentContext();

Best regards,
Roland

Thank you very much! You have solved my problem.

I change demo code planet to add these codes.

Thanks, this problem has been solved.