title: Draw Image After scale and rotate it, to other image iOS
body: <p>I have and UIImageView with a smaller image than original image. and then i added many other UIImageView to the main imageview as the subviews. I also scale and rotate many subviews(imageview). Now i want to create the image from the original image with all sub view image attach on imageview, but keep position. my question is how can i draw many subview images into original image after scale and rotate them. i used CGContextRotateCTM but seem to be it rotate too much. Please help me
  my sample code is</p>
  
  <pre><code>CGContextRef context = UIGraphicsGetCurrentContext();
  [originalImage drawAtPoint:CGPointZero];
  for(UIView *aView in [self.mainImageView subviews]){
      float rate = 1000/self.mainImageView.frame.size.width;
      if(aView.tag != DELETE_ATTACH_IMAGEVIEW_TAG &amp;&amp; aView.tag != ROTATE_ZOOM_IMAGEVIEW_TAG){
          CGRect rect = CGRectMake(aView.frame.origin.x*rate, aView.frame.origin.y*rate, aView.frame.size.width *rate, aView.frame.size.height*rate);
          if([aView isKindOfClass:[CustomImageView class]]){
              CustomImageView *temp = (CustomImageView *)aView;
              float rotation = [temp rotation];
              UIImage *tempImage= temp.image;
              CGContextRotateCTM(context, rotation);
              [tempImage drawInRect:rect];
          }
  
      }
  
  }
  originalImage = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  </code></pre>