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 6094015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:37:42+00:00 2026-05-23T12:37:42+00:00

I want to rotate an UIButton at 180 degrees clockwise. But it always rotate

  • 0

I want to rotate an UIButton at 180 degrees clockwise. But it always rotate counterclockwise.

This is how I tried:

CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.3];

myButton.transform = CGAffineTransformRotate( myButton.transform, M_PI);

[UIView commitAnimations];

also this:

myButton.transform = CGAffineTransformRotate( myButton.transform, - M_PI);

What am I doing wrong?

  • 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-23T12:37:42+00:00Added an answer on May 23, 2026 at 12:37 pm

    I’ve had a similar experience, and my best guess is the following:

    The rotation transform translates to a net result, meaning an absolute rotation. Since rotating -PI and +PI results in the same net effect (both 180 degrees), the animation ends up always choosing the default direction; which seems to be counterclockwise on iOS.

    By setting it to a value slightly more negative than -M_PI, as @kishorebjv mentioned, the shortest rotation path is through the positive direction (switching the animation to clockwise). You can see this effect by using M_PI+0.01 or M_PI-0.01. Both are positive numbers, but they result in different directions.

    More verbose explanation:
    Value: M_PI+0.01
    Direction: Counterclockwise
    Reasoning: This is this translates to a rotation of ~180.6,
    which the shortest rotation is thus a negative 179.4 degrees.

    Value: M_PI-0.01
    Direction: Clockwise
    Reasoning: This is this translates to a rotation of ~179.4, 
    which the shortest rotation is thus a positive 179.4 degrees.
    
    And going back to the value given by kishorebjv
    Value: -3.141593
    Direction: Clockwise
    Reasoning: The value is slightly past -180 degrees, recalling PI is 3.1415926
    ....so the shortest rotation is a positive 179 degrees
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Want to rotate UIImage in 90 degrees with this method : static inline
I want to rotate a UIView, but after the rotation the view is resized.
I want do rotate button to 90 degrees but it gets clipped because it
I want to rotate a UIImageView by roughly 10 degrees left/right but have a
My problem is that I want to rotate the UIImageView of a UIButton .
I want to rotate the log like in mySQL, but now for an H2
I want to rotate a single word of text by 90 degrees, with cross-browser
I find this pretty confusing. When you want to rotate a view, it's going
I have a QGraphicsItem (self.rb). I want to rotate this item around a point(self.originPoint)
I created custom SurfaceView which contains circles. And I want to rotate this circle

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.