I am subclassing a UIView and am calling it via a detail view controller. When I load it, it shows up with the right dimensions and positioning, however it is just a black square... When I just put a UIView into interface builder with the class, it works. I don't think draw rect is called. Heres my code:
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
[self setNeedsDisplay];
}
return self;
}
- (void)drawRect:(CGRect)rect
{
// Drawing code
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 255.0, 255.0, 0, 1);
CGContextStrokeRect(context, CGRectMake(0, 0, 50, 50));
}
and I call it like so:
GameBox *boxy = [[GameBox alloc] initWithFrame:CGRectMake(50, 50, 50, 50)];
[self.view addSubview: boxy];