I've got a view in my app with a meter. The meter has a needle that rotates so far depending on a set of booleans I pass to it. The problem is that I am having a lot of trouble just getting the needle to rotate properly.
needle.layer.anchorPoint = CGPointMake(0.85, 0.5); // Set point of rotation
if(isHelpful == true)
{
// rotate only a little
needle.transform = CGAffineTransformMakeRotation(7*M_PI/180);
}
if(isNeeded == true)
{
// rotate 95 degrees
needle.transform = CGAffineTransformMakeRotation(95*M_PI/180);
}
if(isCritical == true)
{
// rotate 175 degrees
needle.transform = CGAffineTransformMakeRotation(175*M_PI/180);
}
This makes the needle move rotate perfectly, but it also changes its position for some reason, moving all over my nib. I need the image to stay in the same location on my nib and rotate around a specific axis to a degree I determine.
The image is 145x36 and its axis point is at 127x18.