6

Quick and hopefully obvious question.

I have a progmatically created button in my iPhone app that I wish to rotate 45 degrees clockwise, named buttonuq , how can I do this?

1 Answer 1

18

You can use a transformation like :

yourButton.transform = CGAffineTransformMakeRotation(45.0*M_PI/180.0);

Good Luck !

7
  • thanks, I'd been given the impression this only worked for image objects.
    – David26th
    Commented Sep 26, 2010 at 19:45
  • Indeed - upon trying I receive this message error: incompatible type for argument 1 of 'setTransform:'
    – David26th
    Commented Sep 26, 2010 at 19:50
  • My fault, I edited with the good function ( CGAffineTransformMakeRotation )
    – Vinzius
    Commented Sep 26, 2010 at 20:42
  • Thanking you - I'll not be programming tonight but shall explore this fully once I get the opportunity (work comittments I'm afraid to say!)
    – David26th
    Commented Sep 28, 2010 at 16:08
  • Just had another look at this and noticed while the rotation works, it automagically sticks the button in the top left corner of my screen - any ideas? It works fine other than that (iPhone iOS 4.1 on a 3GS)
    – David26th
    Commented Oct 16, 2010 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.