title: Change color of a custom UIButton on .selected state
body: <p>I have designed a radial gradient button for my app's home screen:</p>
  
  <pre><code>    class RadialGradientButton: UIButton {
  
      var insideColor: UIColor = ColorScheme.limeGreen
      var outsideColor: UIColor = UIColor.white
  
      var gradientLocation: CGFloat = 0.9
  
      override func draw(_ rect: CGRect) {
          let colors = [insideColor.cgColor, outsideColor.cgColor] as CFArray
          let center = CGPoint(x: rect.size.width / 2, y: rect.size.height / 2)
  
          let endRadius = rect.size.width / 2
  
          let gradient = CGGradient(colorsSpace: nil, colors: colors, locations: [gradientLocation, 1.0])
  
          UIGraphicsGetCurrentContext()!.drawRadialGradient(gradient!, startCenter: center, startRadius: 0.0, endCenter: center, endRadius: endRadius, options: .drawsBeforeStartLocation)
      }
  
      }
  </code></pre>
  
  <p>Now with this button I've ran into a user experience issue: when the button is tapped, its appearance is not changed in any way because of gradient color settings. I want it to behave like any system button - that is, <code>insideColor</code> should get darker on <code>.selected</code> state.</p>
  
  <p>I've tried to play around with <code>setNeedsDisplay()</code> when <code>Touch Down</code> and <code>Touch Up Inside</code> events are triggered, but this method does not perform immediate redrawing, plus can be harsh on performance.</p>
  
  <p>Maybe someone here can lead me in a right direction.</p>