Reputation: 1011
I have a table view cell with images and labels. I want to add an animation that an image duplicate of a selected cell fly to a point outside the tableview.
I have passed the tableview cell pointer out of the tableview controller. And when I do the duplication, I found the frame of the original image can not be used ouside its superview, i.e. the cell. How could I convert the frame to the [0,0,1024,768] coordiation system? Thanks!
animateImageView = [[UIImageView alloc] initWithImage:cell.thumbnail.image];
[animateImageView setFrame:cell.thumbnail.frame];
[self.view addSubview:animateImageView];
[UIView animateWithDuration:1 delay:0
options:UIViewAnimationCurveEaseIn
animations:^(void) {
[UIView setAnimationTransition:103 forView:animateImageView cache:YES];
[UIView setAnimationPosition: CGPointMake(262, 723)];
}
completion:^(BOOL finished) {
[animateImageView removeFromSuperview];
}
];
[animateImageView release];
Upvotes: 2
Views: 2547
Reputation: 13716
The convertPoint:toView:
method on the UIView
object should give you what you need.
- (CGPoint)convertPoint:(CGPoint)point toView:(UIView *)view
view
The view with point in its coordinate system. If view is nil, this method instead converts from window base coordinates. Otherwise, both view and the receiver must belong to the same UIWindow object.
You could do something along the lines of:
CGPoint point = [self.view convertPoint:self.view.frame.origin toView:nil];
Upvotes: 3