title: UIView resizing after rotation with CGAffineTransform view size is unpredictable
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5802830/weird-behavior-of-uiview-frame-after-rotation-in-iphone">Weird behavior of UIView frame after rotation in iPhone</a>  </p>
  </blockquote>
  
  
  
  <p>I am doing an app which has a feature to rotate and re size a view. i have  implemented this feature but i do face an issue.</p>
  
  <p><strong>My problem</strong></p>
  
  <p>The View wil be resized when dragging its four corners, after resizing it i can  rotate the view in both directions. </p>
  
  <p>Once the rotation is done, if i try again to resize the view by dragging its corner, the view's size gone to unpredictable value and its moving all around the screen.</p>
  
  <p><strong>Similar Problem</strong></p>
  
  <p>I googled lot but i did not get any perfect answer. some people has asked same question but none of them get any good result. I spend lots of time on it but i could not solve it. please help me out
  Following are the list of similar questions:</p>
  
  <p><a href="https://stackoverflow.com/questions/5587168/uiview-resizing-after-rotation-with-cgaffinetransform">similar question link : 1</a></p>
  
  <p><a href="https://stackoverflow.com/questions/8064089/applying-scaling-and-rotation-on-a-view-using-cgaffinetransform">similar question link : 2</a></p>
  
  <p><strong>My sample code</strong></p>
  
  <p><a href="http://dl.dropbox.com/u/43007975/AEMobile%20App%20build%20Enterprise/sampleImgMve.zip" rel="nofollow noreferrer">link</a></p>
  
  <p><strong>Code to resize the view</strong></p>
  
  <p><strong>Touches Began method</strong></p>
  
  <pre><code>- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
  
  UITouch *touch = [[event allTouches] anyObject];
  
  NSLog(@"[touch view]:::%@",[touch view]);
  
  touchStart = [[touches anyObject] locationInView:testVw];
  isResizingLR = (testVw.bounds.size.width - touchStart.x &lt; kResizeThumbSize &amp;&amp; testVw.bounds.size.height - touchStart.y &lt; kResizeThumbSize);
  isResizingUL = (touchStart.x &lt;kResizeThumbSize &amp;&amp; touchStart.y &lt;kResizeThumbSize);
  isResizingUR = (testVw.bounds.size.width-touchStart.x &lt; kResizeThumbSize &amp;&amp; touchStart.y&lt;kResizeThumbSize);
  isResizingLL = (touchStart.x &lt;kResizeThumbSize &amp;&amp; testVw.bounds.size.height -touchStart.y &lt;kResizeThumbSize);    
  }
  </code></pre>
  
  <p><strong>Touches Moved Method</strong></p>
  
  <pre><code>- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
  CGPoint touchPoint = [[touches anyObject] locationInView:testVw];
  CGPoint previous=[[touches anyObject]previousLocationInView:testVw];
  
  
  
  
  float  deltaWidth = touchPoint.x-previous.x;
  float  deltaHeight = touchPoint.y-previous.y;
  
  NSLog(@"CVTM:%@",NSStringFromCGRect(testVw.frame));
  
  
  if (isResizingLR) {
      testVw.frame = CGRectMake(testVw.frame.origin.x, testVw.frame.origin.y,touchPoint.x + deltaWidth, touchPoint.y + deltaWidth);
  }  
  if (isResizingUL) {
      testVw.frame = CGRectMake(testVw.frame.origin.x + deltaWidth, testVw.frame.origin.y + deltaHeight, testVw.frame.size.width - deltaWidth, testVw.frame.size.height - deltaHeight);
  } 
  if (isResizingUR) {
      testVw.frame = CGRectMake(testVw.frame.origin.x ,testVw.frame.origin.y + deltaHeight,  testVw.frame.size.width + deltaWidth, testVw.frame.size.height - deltaHeight);      
  } 
  if (isResizingLL) {
      testVw.frame = CGRectMake(testVw.frame.origin.x + deltaWidth ,testVw.frame.origin.y ,  testVw.frame.size.width - deltaWidth, testVw.frame.size.height + deltaHeight);   
  }
  
  if (!isResizingUL &amp;&amp; !isResizingLR &amp;&amp; !isResizingUR &amp;&amp; !isResizingLL) {
      testVw.center = CGPointMake(testVw.center.x + touchPoint.x - touchStart.x,testVw.center.y + touchPoint.y - touchStart.y);
  }
  
  }
  </code></pre>
  
  <p>First Step before resizing <img src="https://i.stack.imgur.com/LMGCa.png" alt=""> </p>
  
  <p>Secondly i resize  and rotate it<img src="https://i.stack.imgur.com/7eWPE.png" alt=""></p>
  
  <p>Thirdly i try to resize it but it shifts back to its original position <img src="https://i.stack.imgur.com/JiV7W.png" alt=""></p>
  
  <p>These are the updated screens for your reference...</p>