Iphone UIView大小调整和旋转问题

Iphone UIView大小调整和旋转问题,iphone,objective-c,Iphone,Objective C,嗨,朋友们,在我的应用程序中,我想允许用户调整图像的大小、旋转和翻转, 这里我使用了下面的代码来调整大小 CGFloat angleToRotate ;CGPoint currentTouchPoint,previousTouchPoint; UITouch *touch; - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ touch = [[event allTouches] anyObject];

嗨,朋友们,在我的应用程序中,我想允许用户调整图像的大小、旋转和翻转, 这里我使用了下面的代码来调整大小

CGFloat angleToRotate ;CGPoint currentTouchPoint,previousTouchPoint; UITouch *touch;

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

   touch = [[event allTouches] anyObject];


//if (![touch.view isKindOfClass:[vw class]]) {
touchStart = [[touches anyObject] locationInView:self];
kResizeThumbSize=15; 



isResizingLR = (self.bounds.size.width - touchStart.x < kResizeThumbSize && self.bounds.size.height - touchStart.y < kResizeThumbSize); 

 isResizingUL = (touchStart.x <kResizeThumbSize && touchStart.y <kResizeThumbSize);

isResizingUR = (self.bounds.size.width-touchStart.x < kResizeThumbSize && touchStart.y<kResizeThumbSize);
isResizingLL = (touchStart.x <kResizeThumbSize && self.bounds.size.height -touchStart.y <kResizeThumbSize);



}



- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{


UITouch *touch = [[event allTouches] anyObject];

currentTouchPoint = [touch locationInView:self.superview];
previousTouchPoint = [touch previousLocationInView:self.superview];

CGPoint touchPoint1 = [[touches anyObject] locationInView:self.superview];
CGPoint previous1=[[touches anyObject]previousLocationInView:self.superview];


CGPoint touchPoint = [[touches anyObject] locationInView:self];

CGPoint previous=[[touches anyObject]previousLocationInView:self];


float  deltaWidth = touchPoint.x-previous.x;
float  deltaHeight = touchPoint.y-previous.y;


float  deltaWidth1 = currentTouchPoint.x-previousTouchPoint.x;
float  deltaHeight1 = currentTouchPoint.y-previousTouchPoint.y;


CGFloat newW= self.superview.frame.size.width+deltaWidth1;



if (isResizingLR) {


        self.superview.frame = CGRectMake(self.superview.frame.origin.x, self.superview.frame.origin.y,self.superview.frame.size.width+deltaWidth1,self.superview.frame.size.height+deltaHeight1);

     self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y,self.frame.size.width+deltaWidth,self.frame.size.height+deltaHeight);

[self setNeedsDisplayInRect:CGRectMake(self.frame.origin.x, self.frame.origin.y,self.frame.size.width+deltaWidth,self.frame.size.height+deltaHeight)];


}  
if (isResizingUL) {
    self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width - deltaWidth, self.frame.size.height - deltaHeight);


    self.superview.frame = CGRectMake(self.superview.frame.origin.x + deltaWidth1, self.superview.frame.origin.y + deltaHeight1, self.superview.frame.size.width - deltaWidth1, self.superview.frame.size.height - deltaHeight1);

    [self setNeedsDisplayInRect:CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width - deltaWidth, self.frame.size.height - deltaHeight)];

} 

if (isResizingUR) {

    self.frame = CGRectMake(self.frame.origin.x ,self.frame.origin.y,  self.frame.size.width + deltaWidth, self.frame.size.height - deltaHeight); 

    self.superview.frame = CGRectMake(self.superview.frame.origin.x ,self.superview.frame.origin.y+deltaHeight1,  self.superview.frame.size.width + deltaWidth1, self.superview.frame.size.height - deltaHeight1);  

    [self setNeedsDisplayInRect:CGRectMake(self.frame.origin.x ,self.frame.origin.y,  self.frame.size.width + deltaWidth, self.frame.size.height - deltaHeight)];
       } 
if (isResizingLL) {
    self.frame = CGRectMake(self.frame.origin.x  ,self.frame.origin.y ,  self.frame.size.width - deltaWidth, self.frame.size.height + deltaHeight); 

    self.superview.frame = CGRectMake(self.superview.frame.origin.x + deltaWidth1 ,self.superview.frame.origin.y ,  self.superview.frame.size.width - deltaWidth1, self.superview.frame.size.height + deltaHeight1); 
    [self setNeedsDisplayInRect:CGRectMake(self.frame.origin.x  ,self.frame.origin.y ,  self.frame.size.width - deltaWidth, self.frame.size.height + deltaHeight)];

     CGSize supersize=self.superview.frame.size;
    NSLog(@"superview frame in resize: %@",NSStringFromCGSize(supersize));

}


if (!isResizingUL && !isResizingLR && !isResizingUR && !isResizingLL) {

CGPoint center = CGPointMake(CGRectGetMidX([self.superview bounds]), CGRectGetMidY([self.superview bounds]));

//    [self.superview setContentMode:UIViewContentModeRedraw];

CGFloat angleInRadians = atan2f(currentTouchPoint.y - center.y, currentTouchPoint.x - center.x) - atan2f(previousTouchPoint.y - center.y, previousTouchPoint.x - center.x);

     CGFloat angleInRadians1 = atan2f(touchPoint.y - center.y, touchPoint.x - center.x) - atan2f(previous.y - center.y, previous.x - center.x);


   [self.superview setTransform:CGAffineTransformRotate([self.superview transform], angleInRadians)];




}
CGFloat角度旋转;CGPoint currentTouchPoint、previousTouchPoint;UITouch*触摸;
-(无效)触摸开始:(NSSet*)触摸事件:(UIEvent*)事件{
touch=[[event alltouchs]anyObject];
//如果(![touch.view是类别:[vw类别]]){
touchStart=[[触摸任何对象]位置查看:自];
kResizeThumbSize=15;
isResizingLR=(self.bounds.size.width-touchStart.xisResizingUL=(touchStart.x我已经使用了uitouch如何与您的代码朋友建立联系?
use this code for change view size 

[UIView animateWithDuration:2
                          delay:1.0
                        options: UIViewAnimationCurveEaseOut
                     animations:^{
                         // set your resize image;
                     } 
                     completion:^(BOOL finished){
                         NSLog(@"Done!");
                     }];

 yourview.transform = CGAffineTransformMakeRotation(M_PI_2*1.90);//change 1.90 your transform
     [UIView commitAnimations];