title: Stumped by math: Adjust alpha based on UIGestureRecognizer panning
body: <p>I’m fairly certain there is an obvious answer to be had here, and perhaps I’m just too tired to see it, but here goes:</p>
  
  <p>I have a <code>UIPanGestureRecognizer</code>. It’s wired up to move a view around.</p>
  
  <p>I have a subview in this view, that I’d like to adjust the <code>alpha</code> of, when the view is being panned.</p>
  
  <p>The view can only be panned horizontally, so that eliminates some math.</p>
  
  <p>The subview in question begins with an <code>alpha</code> of <code>1.0</code>. While the superview is panning, I would like to adjust the alpha of the subview so that it is proportionally lower and lower, until it reaches a minimum <code>alpha</code> of <code>0.3</code>.</p>
  
  <p>My code is not much at this point, but effectively looks like this:</p>
  
  <pre><code>- (void) someMethodForRecognizer: (UIGestureRecognizer *) recognizer {
      // do stuff here
  
      if (recognizer.state == UIGestureRecognizerStateChanged) {
          // do fancy math here
      }
  
      // do more stuff here
  }
  </code></pre>
  
  <p><strong>What kind of fancy math do I need to be doing to calculate the correct <code>alpha</code> to apply at any given moment during <code>UIGestureRecognizerStateChanged</code>?</strong></p>
  
  <p>(Assume that the relevant state-related ivars are set and available, and feel free to add any that may not seem obvious.)</p>
  
  <p>(I’m really a lazy idiot, aren’t I?)</p>