Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3990910
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:33:05+00:00 2026-05-20T06:33:05+00:00

I want to rotate the image around its center point.The problem i am facing

  • 0

I want to rotate the image around its center point.The problem i am facing is i need to get the angle to calculate in touch moved event (i dont want to use multi touch).I am current using the below code

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

NSArray *allTouches = [touches allObjects]; 
gestureStartPoint = gestureMovedPoint;//i am getting the gestureStartPoint on touch began event

gestureMovedPoint = [[allTouches objectAtIndex:0] locationInView:[self superview]];

NSLog(@"gestureMovedPoint = %@",NSStringFromCGPoint(gestureMovedPoint));

}

CGFloat previousAngle = [self angleBetweenPoints:gestureStartPoint second11:gestureMovedPoint]; // atan2(gestureMovedPoint.y - gestureStartPoint.y, gestureMovedPoint.x - gestureStartPoint.x) * 180 / M_PI;
CGFloat currentAngle =atan2(self.transform.b, self.transform.a);//atan2(gestureMovedPoint.y - gestureStartPoint.y,gestureMovedPoint.x - gestureStartPoint.x) * 180 / M_PI;



CGFloat angleToRotate = currentAngle - previousAngle;



float xpoint = (((atan2((gestureMovedPoint.x - gestureStartPoint.x) , (gestureMovedPoint.y - gestureStartPoint.y)))*180)/M_PI);

    CGAffineTransform transform = CGAffineTransformMakeRotation(angleToRotate-100);



self.transform = transform;

Kindly help me find the solution as i am stuck here and need to complete this application very soon as there is a dead line.
Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:33:05+00:00Added an answer on May 20, 2026 at 6:33 am

    Glad I remember triginometry

    
    -(void)degreesToRotateObjectWithPosition:(CGPoint)objPos andTouchPoint:(CGPoint)touchPoint{
    
       float dX = touchPoint.x-objPos.x;        // distance along X
       float dY = touchPoint.y-objPos.y;        // distance along Y
       float radians = atan2(dY, dX);          // tan = opp / adj
    
       //Now we have to convert radians to degrees:
       float degrees = radians*M_PI/360;
    
       return degrees;
    }
    

    Once you have your nice method, just do this in the touch event method. (I forgot what it’s called…)

    CGAffineTransform current = view.transform;
    
    [view setTransform:CGAffineTransformRotate(current,
    [self degreesTorotateObjectWithPosition:view.frame.origin
    andTouchPoint:[touch locationInView:parentView]] //Note: parentView = The view that your object to rotate is sitting in.

    This is pretty much all the code that you’ll need.The math is right, but I’m not sure about the setTransform stuff. I’m at school writing this in a browser. You should be able to figure it out from here.

    Good luck,

    Aurum Aquila

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In flash10 I can easly rotate an image around its center in 3D space.
I want to rotate Image Control using LayoutTransform but the problem i am facing
I want to rotate the below image on a center point using one finger
Ok, So I have an Image object that I want to rotate around its
Hi I want to rotate a control on its right bottom point(like a clock
I have an object which I first want to rotate (about its own center)
I want to rotate image (left and right rotation) with angle 90.I am using
i want to rotate image in quartz 2d around one corner..i want to make
I'm trying to rotate an image around the center. This works generally using RotateAnimation,
I want to rotate a imageview around a point. The imageview is referring to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.