title: Rotated images having jagged borders even after adding transparent border
body: <p>In my app I need to rotate images.I rotated the images but they have jagged borders.I googled and found that adding transparent border solves the problem, but the borders are still jagged.</p>
  
  <p>My code is </p>
  
  <pre><code>-(void)CreateRotatedImage:(UIImage *)image Number:(int)Number    
              {    
                  UIImage *ImageBackground=[UIImage imageNamed:@"white-highlight.png"];
  
  CGSize ImageBackgroundSize = CGSizeMake(60, 50);
  UIGraphicsBeginImageContext(ImageBackgroundSize);
  CGRect ImageBackgroundRect = CGRectMake(0.0, 0.0, ImageBackgroundSize.width, ImageBackgroundSize.height);
  [ImageBackground drawInRect:ImageBackgroundRect];
  ImageBackground = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  
  
  
  CGSize ImageSize = CGSizeMake(50, 40);
  UIGraphicsBeginImageContext(ImageSize);
  CGRect ImageRect = CGRectMake(0.0, 0.0, ImageSize.width, ImageSize.height);
  [image drawInRect:ImageRect];
  image = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  
  
  
  
  
  UIGraphicsBeginImageContext(CGSizeMake(60,50));
  [ImageBackground drawAtPoint:CGPointMake(0,0)];
  [image drawAtPoint:CGPointMake(5,5)];
  // MyscrollView.backgroundColor = [UIColor clearColor];
  UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  
  
  
  UIImage *pin=[UIImage imageNamed:@"pin.png"];
  UIGraphicsBeginImageContext(CGSizeMake(60,50));
  [newImage drawAtPoint:CGPointMake(0,0)];
  [pin drawAtPoint:CGPointMake(newImage.size.height/2,0)];
  // MyscrollView.backgroundColor = [UIColor clearColor];
  UIImage *IntermediateImage = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  
  
  
  CGRect imageRrect = CGRectMake(0, 0, IntermediateImage.size.width, IntermediateImage.size.height);
  UIGraphicsBeginImageContext( imageRrect.size ); 
  [IntermediateImage drawInRect:CGRectMake(2,2,IntermediateImage.size.width-2,IntermediateImage.size.height-2)];    
     UIImage *i = UIGraphicsGetImageFromCurrentImageContext();  
      UIGraphicsEndImageContext();
  
  
  
  CGSize iSize = CGSizeMake(110, 70);
  
  UIGraphicsBeginImageContext(iSize);
  
  CGContextRef context = UIGraphicsGetCurrentContext();
  CGContextSetAllowsAntialiasing(context, YES);
   CGContextSetShouldAntialias(context, YES);
  CGContextRotateCTM (context, radians(5));
  [i drawAtPoint:CGPointMake(0, 0)];
  UIImage *RotatedImage=UIGraphicsGetImageFromCurrentImageContext();
  
  //RotatedImage=[RotatedImage resizedImage:iSize interpolationQuality:kCGInterpolationHigh];  
  
  
  }
  </code></pre>