I'm trying to create my own UIView subclass. I've placed it on my view in Interface Builder by dragging out a UIView, then specifying my subclass's name in the Class Identity field. Yet my UIView does not draw itself.
Here--in a simplified example--is the code in my UIView subclass:
- (id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super initWithCoder:aDecoder])
{
UILabel* label = [[[UILabel alloc] initWithFrame:self.frame] autorelease];
label.text = @"Hello.";
label.textColor = [UIColor whiteColor];
[self addSubview:label];
}
return self;
}
I've seen reference to overriding drawRect:, but honestly I have no idea what I'd do in that method. I'm sure I'm doing something obviously wrong, but I have no idea what.
Any suggestions would be greatly appreciated!
Thanks.