title: UIView transparent gradient
body: <p>Given an arbitrary UIView on iOS, is there a way using Core Graphics (CAGradientLayer comes to mind) to apply a "foreground-transparent" gradient to it?</p>
  
  <p>I can't use a standard CAGradientLayer because the background is more complex than a UIColor. I also can't overlay a PNG because the background will change as my subview is scrolled along its parent vertical scrollview (see image).</p>
  
  <p>I have a non-elegant fallback: have my uiview clip its subviews and move a pre-rendered gradient png of the background as the parent scrollview is scrolled.</p>
  
  <p><img src="https://i.stack.imgur.com/wOwqS.png" alt="transparent uiview gradient problem"></p>