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

Thank you very much! You have solved my problem.

I change demo code planet to add these codes.