I know a ton of people have asked the same question, but none of the proposed solutions seem relevant, so I'm asking again: I have the following block of code:
UIImageView *moneyHolder = [[UIImageView alloc] initWithImage:moneyImage];
if([paymentMethod.viewed intValue] == 0){
//CGRect targetFrame = CGRectMake(0, cell.frame.size.height/2-3, cell.frame.size.width, targetHeight);
CGRect targetFrame = moneyHolder.frame;
targetFrame.origin.y = cell.frame.size.height/2-3;
NSLog(@"animating");
[UIView animateWithDuration:2
delay:0
options: UIViewAnimationCurveEaseOut
animations:^{
moneyHolder.frame = targetFrame;
}
completion:^(BOOL finished){
NSLog(@"done");
}
];
}
Which I would THINK should animate my moneyHolder frame. Unfortunately, this seems to happen immediately rather than with a duration of 2 seconds. I can verify this with timestamps from my log:
2012-05-11 03:41:50.102 AgilePoet[5824:15203] animating
2012-05-11 03:41:50.116 AgilePoet[5824:15203] done
Does anyone have any thoughts on why this might be happening? All the other questions on the subject focused on the property not being animatable, but I know that an imageview frame is animate-able. The only thing I can think is that this code is written inside my
-tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath method.
Thanks in advance!
To quote the docs:
frame The frame rectangle, which describes the view’s location and size in its superview’s coordinate system.
Changes to this property can be animated. However, if the transform property contains a non-identity transform, the value of the frame property is undefined and should not be modified. In that case, you can reposition the view using the center property and adjust the size using the bounds property instead.
If you, or some other code, has changed the transformation matrix for the view, changes to the frame property don't work as expected.
You should change the center property (to move the view) and bounds property (to change it's size) instead. Those properties behave as expected.
in my case animation called in viewdidload method. Don't do this. Try on viewWillAppear
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With