Custom UIView's drawRect nunca se llama si el cuadro inicial es CGRectZero
Tengo una subclase personalizada bastante simple de UIView:
#import "BarView.h"
#import <QuartzCore/QuartzCore.h>
@implementation BarView
@synthesize barColor;
- (void)drawRect:(CGRect)rect
{
NSLog(@"drawRect");
// Draw a rectangle.
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, self.barColor.CGColor);
CGContextBeginPath(context);
CGContextAddRect(context, self.bounds);
CGContextFillPath(context);
}
- (void)dealloc
{
self.barColor = nil;
[super dealloc];
}
@end
Si llamo initWithFrame: rect en esta clase con algún rect distinto de cero, funciona bien; pero cuando llamo initWithFrame: CGRectZero, drawRect se llama -nunca-, incluso después de modificar el marco de la vista a un rect no cero.
Ciertamente entiendo por qué una vista con un marco cero nunca tendría su drawRect: llamado, pero ¿por qué nunca se llama incluso después de cambiar el marco?