Littleodie914
Apr 2, 2008, 11:32 AM
Hey all. I'm working on trying to do some custom 2D drawing on the iPhone, and I'm running into some issues. I don't have any Quartz/OpenGL experience, but I know a good bit of Cocoa.
I have a subclass of an UISimpleTableViewCell, and I'm trying to draw a simple triangle in it. I had been drawing squares by creating really small UIViews and just setting their background color, but that's obviously the wrong way to do this. :)
So, here's what I'm trying so far:
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 0.5, 1.0, 0.5, 0.8);
CGRect rect = CGRectMake(0, 0, 200, 200);
CGContextFillRect(context, rect);
And it's not actually drawing anything in the view. Again, I'm a complete beginner in this topic, but I think once I get this figured out, I'd like to move to using the CGContextAddLineToPoint, CGContextAddArc, etc. methods, and I was wondering if you guys could help me out with some *very* simple sample code. Eg., maybe just drawing a rectangle and filling it.
I've looked at a lot of Apple's sample code related to this topic, but it was a bit over my head. Thanks! :D
Edit: Just for some additional info, the above code is in my Cell's initWithFrame: method, after any subviews are added.
I have a subclass of an UISimpleTableViewCell, and I'm trying to draw a simple triangle in it. I had been drawing squares by creating really small UIViews and just setting their background color, but that's obviously the wrong way to do this. :)
So, here's what I'm trying so far:
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 0.5, 1.0, 0.5, 0.8);
CGRect rect = CGRectMake(0, 0, 200, 200);
CGContextFillRect(context, rect);
And it's not actually drawing anything in the view. Again, I'm a complete beginner in this topic, but I think once I get this figured out, I'd like to move to using the CGContextAddLineToPoint, CGContextAddArc, etc. methods, and I was wondering if you guys could help me out with some *very* simple sample code. Eg., maybe just drawing a rectangle and filling it.
I've looked at a lot of Apple's sample code related to this topic, but it was a bit over my head. Thanks! :D
Edit: Just for some additional info, the above code is in my Cell's initWithFrame: method, after any subviews are added.
