title: iOS7 custom button become transparent when highlighted
body: <p>I just create my own custom button that seem like iOS6 and earlier buttons but on iOS7 my CustomButton turn transparent when highlighted.
  I have try to set property adjustsImageWhenHighlighted at NO but nothing change, [self setAlpha:1.f] doesn't work either.</p>
  
  <p>Following, my init method: </p>
  
  <pre><code>-(void) baseInit:(CGRect)frame :(CGFloat *)colorsNormal :(CGFloat *)colorsHighlighted :(CGFloat *)colorsDisabled
  {
  
      self.layer.borderWidth=1.0f;
      self.layer.borderColor=[[UIColor colorWithRed:0.67f green:0.67f blue:0.67f alpha:1.0f] CGColor];
      self.layer.cornerRadius=7.0f;
  
      self.clipsToBounds = YES;
  
      UIImage *image = [self generateUIImageWithGradient:frame :colorsNormal];
      [self setBackgroundImage:image forState:UIControlStateNormal];
      [self setTitleColor:[UIColor colorWithRed:0.22f green:0.33f blue:0.53f alpha:1.0f] forState:UIControlStateNormal];
  
      UIImage *image2 = [self generateUIImageWithGradient:frame :colorsHighlighted];
      [self setBackgroundImage:image2 forState:UIControlStateHighlighted];
      [self setTitleColor:[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f] forState:UIControlStateHighlighted];
  
      UIImage *image3 = [self generateUIImageWithGradient:frame :colorsDisabled];
      [self setBackgroundImage:image3 forState:UIControlStateDisabled];
  }
  
  -(id) generateUIImageWithGradient:(CGRect)frame :(CGFloat *)colors
  {
      CGSize size = CGSizeMake(frame.size.width, frame.size.height);
      UIGraphicsBeginImageContextWithOptions(size, NO, 0);
      CGContextRef context = UIGraphicsGetCurrentContext();
  
      CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
  
      size_t gradientNumberOfLocations = 2;
      CGFloat gradientLocations[2] = {0.0, 1.0};
  
      CGGradientRef gradient = CGGradientCreateWithColorComponents(colorspace, colors, gradientLocations, gradientNumberOfLocations);
  
      CGContextDrawLinearGradient(context, gradient, CGPointMake(0, 0), CGPointMake(0, size.height), 0);
  
      UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
  
      CGGradientRelease(gradient);
      CGColorSpaceRelease(colorspace);
      UIGraphicsEndImageContext();
  
      return image;
  }
  </code></pre>
  
  <p>And my method call :</p>
  
  <pre><code>CGFloat colorsNormal [] = {1.0f,1.0f,1.0f,1.0f,1.0f,1.0f,1.0f,1.0f};
  CGFloat colorsHighlighted [] = {0.03f,0.55f,0.97f,1.0f,0.0f,0.37f,0.90f,1.0f};
  CGFloat colorsDisabled [] = {1.0f,1.0f,1.0f,1.0f,1.0f,1.0f,1.0f,1.0f};
  
  [self baseInit:rect :colorsNormal :colorsHighlighted :colorsDisabled];
  </code></pre>
  
  <p>That work like a charm on iOS6 and NormalState work on iOS7.</p>
  
  <p>Thanks for your help</p>