title: Fitting View Frame around Scaled CALayer
body: <p>In the following method, I'm simply enlarging a bunch of <code>CAShapeLayers</code> which are attached to my views layer property by using <code>CATransform3DMakeScale</code>. I'm able to enlarge  the shape layers correctly, but am having a tough time getting the view frame to enlarge and fit around the graphic produced by the shape layers like it should. Everything is the same size, ie the view frame is the same size as all of the shape layers. </p>
  
  <p>Anyone have any suggestions on how to fix this? I've tried altering the views transform property as well as the views layer transform property. Not sure what I'm missing here.</p>
  
  <pre><code>- (void) setSize:(CGSize)size
  {
      CATransform3D transform = CATransform3DMakeScale(size.width / (self.graphic.initialSize.width), size.height / (self.graphic.initialSize.height), 1);
      self.layer.sublayerTransform = transform;
      self.frame = CGRectMake(0, 0, size.width, size.height);
      self.graphic.size = CGSizeMake(size.width, size.height);
  }
  </code></pre>
  
  <p>Also for reference, here is how I am setting up the views layer:</p>
  
  <pre><code>- (id)initWithGraphic:(Graphic*)graphic
  {
      self = [super initWithFrame:CGRectZero];
      if (self) 
      {
          self.backgroundColor = [UIColor clearColor];
  
          _graphic = [graphic retain];
  
          self.frame = CGRectMake(0,0, _graphic.initialSize.width, _graphic.initialSize.height);
          self.layer.shouldRasterize = YES;
  
          for (int i = 0; i &lt; [_graphic.shapeLayers count]; i++)
          {
              [self.layer addSublayer:[_graphic.shapeLayers objectAtIndex:i]];
          }
      }
      return self;
  }
  </code></pre>
  
  <p>and here is how I'm setting up one of the shape layers:</p>
  
  <pre><code>CAShapeLayer *outlineShapeLayer = [[CAShapeLayer alloc] init];
  outlineShapeLayer.anchorPoint = CGPointMake(0, 0);
  outlineShapeLayer.fillColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1].CGColor;
  outlineShapeLayer.bounds = shapeLayerFrame;
  outlineShapeLayer.mutablePath = mutablePath;
  </code></pre>