title: Transparent background in CoreGraphics
body: <p>I am trying to get a transparent background in CG but it keeps coming out black.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>- (id)initWithFrame:(CGRect)frame {
      if ((self = [super initWithFrame:frame])) {
          DLog(@"&gt;&gt;&gt; Alloc: DrawingCanvas [0x%X]", (unsigned int)self);
          [self setOpaque:NO];
          [self setBackgroundColor:[UIColor clearColor]];
      }
      return self;
  }
  
  - (void) drawRect:(CGRect)rect
  {
      CGContextRef context = UIGraphicsGetCurrentContext();
      CGRect frame = rect;
      int counter = 3;
  
      CGContextClearRect(context, frame);
      CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
      CGContextFillRect(context, frame);
  }
  </code></pre>
  
  <p>How do I get this code to show a transparent background?</p>