I simply want to center an image view in its superview. Then animate it to another point.
When I put just this it centers the image just fine.
but when I add the animation the image starts off center a little up and to the left.
It's is a for loop because a copy of the image is moving out to each vertex of a polygon.
When I put just this it centers the image just fine.
Code:
CGPoint middle = CGPointMake(bounds.size.width / 2.0, bounds.size.height / 2.0);
UIImageView *buttonImage = [[UIImageView alloc] initWithImage: image];
[self addSubview: buttonImage];
buttonImage.center = middle;
but when I add the animation the image starts off center a little up and to the left.
Code:
for (int arrayPointer = 0; arrayPointer != (pointsForPolygon.count); arrayPointer++)
{
NSValue *theValue =[pointsForPolygon objectAtIndex:arrayPointer];
CGPoint thePoint = [theValue CGPointValue];
UIImageView *buttonImage = [[UIImageView alloc] initWithImage: image];
[self addSubview: buttonImage];
buttonImage.center = middle;
[UIView beginAnimations: @"moveAnimation" context: nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationCurve: UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:10.];
[UIView setAnimationDelegate:self];
CGRect imageSize = buttonImage.frame;
imageSize.size.width /= 10;
imageSize.size.height /= 10;
buttonImage.frame = imageSize;
buttonImage.center = thePoint;
[UIView setAnimationDidStopSelector:@selector(moveAnimationDidStop:finished:context:)];
[UIView commitAnimations];
[buttonImage release];
}
It's is a for loop because a copy of the image is moving out to each vertex of a polygon.