title: Live Xcode's Interface Builder UIView subclass (IB_DESIGNABLE) without drawRect:
body: <p>Is it possible to create a <code>UIView</code> subclass that renders live in Xcode (by adding the <code>IB_DESIGNABLE</code> attribute as explained <a href="https://developer.apple.com/library/ios/recipes/xcode_help-IB_objects_media/chapters/CreatingaLiveViewofaCustomObject.html" rel="nofollow">here</a>) but doesn't have a custom <code>drawRect:</code> method?</p>
  
  <p>We have a custom <code>UIView</code> subclass that uses some <code>CAShapeLayer</code>s which are added to <code>self.layer</code> for drawing (hence, there's no need to override <code>drawRect:</code>). This class works fine on the App, but won't render on Xcode.</p>
  
  <p>If we replicate the code in <code>drawRect:</code> it works, but we'd prefer to keep the drawing to happen automatically on the layers.</p>
  
  <p>Can this be done?</p>
  
  <hr>
  
  <p>I also tried doing</p>
  
  <pre><code>- (void)drawRect:(CGRect)rect
  {
      CGContextRef currentContext = UIGraphicsGetCurrentContext();
      CGContextMoveToPoint(currentContext, self.myLayer1.frame.origin.x, self.myLayer1.frame.origin.y);
      [self.myLayer1 renderInContext:currentContext];
      CGContextMoveToPoint(currentContext, self.myLayer1.frame.origin.x, self.myLayer1.frame.origin.y);
      [self.myLayer2 renderInContext:currentContext];    
  }
  </code></pre>
  
  <p>which seems to work on the device but not on Xcode's IB.</p>