Jak zmienić rozmiar UIView przy CGAffineTransformIdentity

Robię aplikację, która ma funkcję obracania i zmiany rozmiaru widoku. zaimplementowałem tę funkcję, ale mam problem.

Mój problem

Widok zostanie zmieniony podczas przeciągania jego czterech rogów, po zmianie rozmiaru mogę obracać widok w obu kierunkach.

Gdy obrót zostanie zakończony, jeśli spróbuję ponownie zmienić rozmiar widoku, przeciągając jego róg, rozmiar widoku osiągnie nieprzewidywalną wartość i przesunie się dookoła ekranu.

Poszukałem wiele w końcu mam następujące rozwiązanie

The frame property is undefined when transform != CGAffineTransformIdentity, as per the docs on UIView

Widziałem jedną aplikację, która wdrożyła tę funkcję dokładnie to, co chcę wdrożyć.

Jak zmienić rozmiar UIView po obróceniu UIView

Mój kod do zmiany rozmiaru widoku

Zaczęło się dotykać

- (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 < kResizeThumbSize &&     testVw.bounds.size.height - touchStart.y < kResizeThumbSize);
   isResizingUL = (touchStart.x <kResizeThumbSize && touchStart.y <kResizeThumbSize);
   isResizingUR = (testVw.bounds.size.width-touchStart.x < kResizeThumbSize &&      touchStart.y<kResizeThumbSize);
   isResizingLL = (touchStart.x <kResizeThumbSize && testVw.bounds.size.height -touchStart.y <kResizeThumbSize);    
}

Dotyka Przeniesionych

- (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 && !isResizingLR && !isResizingUR && !isResizingLL) {
testVw.center = CGPointMake(testVw.center.x + touchPoint.x - touchStart.x,testVw.center.y + touchPoint.y - touchStart.y);
 }

 }

questionAnswers(1)

yourAnswerToTheQuestion