I read the following from the One -step affine transform to rotate around a point? :
CGAffineTransform transform = CGAffineTransformMakeTranslation(x, y); transform = CGAffineTransformRotate(transform, a); transform = CGAffineTransformTranslate(transform,-x,-y);
However, when I do this, images are converted all over the map and rarely across the screen.
I tried a little to create a system in which images will be placed; if you run the loop and put a few values, a spiral will appear. However, although I could ultimately unravel the connection between the rotation of the images and the points that I wanted them to rotate, I wanted to ask for a better solution for “I have an image here, I think this moment is its center, I want so that it rotates around its center in this value, but does not move otherwise. "
I am trying to make a modified port http://JonathansCorner.com/ancient-clock/ , and now I'm trying to put the hour hand. All attempts to make the song and dance higher, and translate it so that its center was in the desired center, failed.
As for the hands of this watch, I can say "I want the hands to be in the next turns", and were they placed correctly around the center?
- EDIT -
The most important part of this code, edited in an attempt to use layers in response to a comment, is this:
UIImage *hourHandImage = [UIImage imageNamed:@"hour-hand.png"]; UIImageView *hourHandView = [[UIImageView alloc] initWithImage:hourHandImage]; float hourRotation = .5; hourHandImage = [UIImage imageNamed:@"hour-hand.png"]; hourHandView = [[UIImageView alloc] initWithImage:hourHandImage]; CGAffineTransform transform = CGAffineTransformMakeTranslation(centerX - 21, -centerY - 121);
Thanks,
- EDIT -
Now something has gone; if i follow some instructions i have:
CGAffineTransform transform = CGAffineTransformMakeTranslation(100 -21, 100 -121); transform = CGAffineTransformRotate(transform, hour / 12.0 * M_PI * 2.0); transform = CGAffineTransformTranslate(transform, -330, 330); hourHandView.transform = transform;
I would like to work on outputting these numbers, but this correctly displays the hour of 9:00.
Thank you for your help!