title: Loss quality image in UIView
body: <p>I've got a problem with my images on my app. In my slide-out menu, I've got an header where i put an image "header.png" which exist in two version "header.png" and "header@2x.png". Here is my code how I implement it in my app:</p>
  
  <pre><code>- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  {
      UIImage *originalImage = [UIImage imageNamed:@"header.png"];
      CGSize destinationSize = CGSizeMake(320, 150);
      UIGraphicsBeginImageContext(destinationSize);
      [originalImage drawInRect:CGRectMake(0,0,destinationSize.width,destinationSize.height)];
      UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
      UIGraphicsEndImageContext();
  
  
      UIImageView *headerView = [[UIImageView alloc] initWithImage:newImage];
      headerView.frame = CGRectMake(0,0, 320,150);
      return headerView;
  }
  </code></pre>
  
  <p>When I run the app on my phone (iPhone 4s), my image is pixelate, the edge are blowed and it's not really clean... I don't know where it comes from.</p>
  
  <p>My images are 320x150px and 640x300px in 72dpi</p>
  
  <p>Thx</p>
  
  <p>--EDIT--</p>
  
  <p>I've solved my problem by using an UIImageView see below:</p>
  
  <pre><code>- (UIImageView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  {
      NSString* fileName = [NSString stringWithFormat:@"header.png"];
      UIImage *newImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:fileName ofType:nil]];
  
      UIImageView *headerView = [[UIImageView alloc] initWithImage:newImage];
      headerView.frame = CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 150);
  
      return headerView;
  }
  </code></pre>