1

Basically what I want is that I want to rotate two images (clock hands for example) around the same anchor point. They should always rotate in the opposite angle as the other clock hand. I've tried using this code below, however it doesn't work. It should work I suppose. What am I doing wrong?

//viewDidLoad
movingview.transform.Label1.layer.anchorPoint = CGPointMake(0.5, 1); 
movingview2.transform.Label1.layer.anchorPoint = CGPointMake(0.5, 0); 

//timer getting called every 0.01 seconds:
rotation += 0.005;
movingview.transform = CGAffineTransformMakeRotation(rotation);
movingview2.transform = CGAffineTransformMakeRotation(M_PI+rotation);
Freddy
  • 810
  • 1
  • 9
  • 19
  • The question risks being closed for "it doesn't work", and it's of the form "what's wrong with my code?". Can you improve the question with images, and with what you've tried to remediate? – danh Jul 09 '14 at 23:50
  • Incidentally, the answer will probably involve setting an anchorPoint... see decent explanation here: http://stackoverflow.com/questions/12208361/why-does-my-view-move-when-i-set-its-frame-after-changing-its-anchorpoint/12208587#12208587 – danh Jul 09 '14 at 23:53
  • You need to set the `layer.position` – user3386109 Jul 10 '14 at 00:02

1 Answers1

0

No need for anchor points. Just use constraints in storyboard to center both around the same point. Then:

self.imageview.transform = CGAffineTransformMakeRotation(M_PI/2); //for 90 degrees
Mika
  • 5,807
  • 6
  • 38
  • 83