background color using core graphics
cocoa-touch, core-graphics, ios, objective-c
Solution
You probably want:
CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
CGContextFillRect(context, self.bounds);
`CGContextFillPath` fills a "path," which you'd have to first build with a series of other calls, like `CGContextAddRect` and `CGContextAddArc`. It's easier just to fill the rect.
Problem
I have the following code in my drawRect: ``` CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor); CGContextFillPath(context); ``` I basically wanted to set the background of this view to be red.. however the code above doesn't do it. What am I doing wrong?