title: How to add a gradient tint color to a UISlider in XCode 6?
body: <p>I'm working on a design application that has a section for selecting colors by three sliders for RGB.
  As we can see in xcode, where we want to select a color by RGB values, the slider tint color is a gradient color that changes when we change the sliders. I want to use this in my application. but I have  no idea about how to do this?</p>
  
  <p>I've found this code in a blog. but didn't work for me.</p>
  
  <pre><code>- (void)setGradientToSlider:(UISlider *)Slider WithColors:(NSArray *)Colors{
  
      UIView * view = (UIView *)[[Slider subviews]objectAtIndex:0];
  
      UIImageView * maxTrackImageView = (UIImageView *)[[view subviews]objectAtIndex:0];
  
      CAGradientLayer * maxTrackGradient = [CAGradientLayer layer];
      CGRect rect = maxTrackImageView.frame;
      rect.origin.x = view.frame.origin.x;
  
      maxTrackGradient.frame = rect;
      maxTrackGradient.colors = Colors;
  
      [maxTrackGradient setStartPoint:CGPointMake(0.0, 0.5)];
      [maxTrackGradient setEndPoint:CGPointMake(1.0, 0.5)];
  
      [[maxTrackImageView layer] insertSublayer:maxTrackGradient atIndex:0];
  
      /////////////////////////////////////////////////////
  
      UIImageView * minTrackImageView = (UIImageView *)[[view subviews]objectAtIndex:1];
  
      CAGradientLayer * minTrackGradient = [CAGradientLayer layer];
      rect = minTrackImageView.frame;
      rect.size.width = maxTrackImageView.frame.size.width;
      rect.origin.x = 0;
      rect.origin.y = 0;
  
      minTrackGradient.frame = rect;
      minTrackGradient.colors = Colors;
  
      [minTrackGradient setStartPoint:CGPointMake(0.0, 0.5)];
      [minTrackGradient setEndPoint:CGPointMake(1.0, 0.5)];
  
      [minTrackImageView.layer insertSublayer:minTrackGradient atIndex:0];
  
  }
  </code></pre>
  
  <p>I would appreciate any helps. Thanks.</p>