开发者

obtain absolute position of a view inside a UITableViewCell

开发者 https://www.devze.com 2023-03-27 07:49 出处:网络
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 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];


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.

Documentation

You could do something along the lines of:

CGPoint point = [self.view convertPoint:self.view.frame.origin toView:nil];
0

精彩评论

暂无评论...
验证码 换一张
取 消