title: iphone sdk transparent subview background
body: <p>I have a main view with a picture on it.</p>
  
  <p>I am trying to add a subview with <code>[self.view addSubview:view2];</code> but I want the view2 background to be transparent. Have tried <strong>opaque=no</strong> and background color to clearcolor and also tried to subclass a uiview and rewrite the drawrect with:</p>
  
  <pre><code>#import "TransparentView.h"
  
  
  @implementation TransparentView
  
  - (id)initWithFrame:(CGRect)frame 
  {
      if (self = [super initWithFrame:frame]) {
          [self setBackgroundColor:[UIColor clearColor]];
          self.opaque=NO;
          self.clearsContextBeforeDrawing=YES;
      }
      return self;
  }
  
  - (void)drawRect:(CGRect)rect 
  {
      CGContextRef context = UIGraphicsGetCurrentContext();
      CGContextClearRect(context, rect);
  
      CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
      CGContextFillRect(context, rect);
  }
  
  
  @end
  </code></pre>
  
  <p>But still doesn't display the background of the subview transparent... any ideas? </p>