views:

64

answers:

1

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?

+2  A: 

Hello

You can use a transformation like :

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

Good Luck !

Vinzius
thanks, I'd been given the impression this only worked for image objects.
David26th
Indeed - upon trying I receive this message error: incompatible type for argument 1 of 'setTransform:'
David26th
My fault, I edited with the good function ( CGAffineTransformMakeRotation )
Vinzius
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
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