title: UIView categories and drop shadow -- being applied twice
body: <p>I've created a category on UIView that allows me to add a drop shadow to the view.  My code for the shadow looks like this:</p>
  
  <pre><code>-(void)addDropShadowWithOffset:(CGFloat)offset {
      UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:self.bounds];
      self.layer.masksToBounds = NO;
      self.layer.shadowColor = [UIColor blackColor].CGColor;
      self.layer.shadowOffset = CGSizeMake(0.0f, offset);
      self.layer.shadowOpacity = 0.5f;
      self.layer.shadowPath = shadowPath.CGPath;
  }
  </code></pre>
  
  <p>It works great.  However, I've noticed that when I rotate the screen the shadow gets redrawn.  The more I rotate it, the more the shadow is redrawn, leading to a shadow much larger than I originally wanted.  </p>
  
  <p>I originally thought about adding a BOOL iVar to the category that would let me track whether or not the shadow has already been drawn.  But, it appears as though I can't add iVars to a category.  So, how can I prevent this code from being run more than once per UIView?  Any suggestions?</p>