title: UIView subclass: drawRect not called
body: <p>I am a beginner in iOS programming, so sorry if my question is a stupid question.</p>
  
  <p>I am trying to make an app which performs custom drawing on a loaded image. </p>
  
  <p>To do it, I found out that a solution is to subclass <code>UIView</code> and edit the <code>drawRect</code> method. </p>
  
  <p>I made that on the following code which activates on an <code>IBAction</code> linked to a button in the Interface Builder storyboard file.</p>
  
  <pre><code>UIImageView *image = [[UIImageView alloc] initWithImage: [UIImage imageNamed:     @"SampleImage.jpg"]]; 
  image.frame = previewView.frame;
  [image setContentMode:UIViewContentModeScaleAspectFit];       
  
  [previewView addSubview:image];
  
  customView *aCustomView = [[customView alloc] initWithFrame: CGRectMake(image.bounds.origin.x, image.bounds.origin.y, image.bounds.size.width, image.bounds.size.height)];
  [previewView addSubview:aCustomView];
  </code></pre>
  
  <p><code>customView</code> is the <code>UIView</code> subclass that I created, whose <code>init</code> and <code>drawRect</code> methods are set like this:</p>
  
  <pre><code>- (id)initWithFrame:(CGRect)frame
  {
      self = [super initWithFrame:frame];
      NSLog(@"INITIALIZING");
      if (self) {
          // Initialization code
          [self setBackgroundColor:[UIColor clearColor]];
      }
      return self;
  }
  
  
  - (void)drawRect:(CGRect)rect
  {
      CGContextRef ctx = UIGraphicsGetCurrentContext();
      NSLog(@"DRAWING");
  
      CGContextClearRect(ctx, rect);
  
      CGContextSetRGBFillColor(ctx, 0, 255, 0, 0.3);
      CGContextFillEllipseInRect(ctx, rect); 
  
      CGContextSetRGBStrokeColor(ctx, 255, 0, 0, 1);
      CGContextSetLineWidth(ctx, 2);
      CGContextStrokeEllipseInRect(ctx, rect);
  }
  </code></pre>
  
  <p>The problem that I have is that no drawing is made and on <code>NSLog</code> I have the "INITIALIZING" message, but not the "DRAWING" drawing. </p>
  
  <p>So basically it makes the <code>initWithFrame</code>, but it doesn't call the <code>drawRect</code> method.</p>
  
  <p>Could you please point me what am I doing wrong?</p>