title: How to add a shadow to the outside of a CALayer object?
body: <p>I'm not sure if this is a duplicate question, but feel free to flag if it it is.</p>
  
  <p>I'm trying to add a shadow to the outside of a CALayer. I currently have a <code>UIImageView</code> within a CALayer that I've made with rounder corners as shown:</p>
  
  <pre><code>CALayer * l = [ImageView layer];
  [l setMasksToBounds:YES];
  [l setCornerRadius:10.0];
  </code></pre>
  
  <p>I've tried to add the additional code:</p>
  
  <pre><code>[l setShadowOffset:CGSizeMake(0, 3)];
  [l setShadowOpacity:0.4];
  [l setShadowRadius:3.0f];
  [l setShouldRasterize:YES];
  </code></pre>
  
  <p>The results are shown in RED where the shadow is applied within the CALayer instead of outside it, and that's what I'd like to achieve in green along the edges:</p>
  
  <p><a href="https://i.stack.imgur.com/u2WWA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u2WWA.png" alt="enter image description here"></a></p>
  
  <p>How can I achieve this while still maintain the rounded corners? Thanks</p>