Search code examples
iosframeuiviewanimationgmgridview

iOS UIView animation changeFrame wrong coordinate system


See the below code. When the frame is "changed" in the animation, it is changed to the coordinate system of the actual cell, and not the coordinate of the whole view. So (0,0) is the origin of the cell NOT the whole view. The cell is in the middle of the screen (part of GMGridView).

What i am trying to accomplish: I need to get the absolute position of the cell in the WHOLE view, and from there animate a framechange (resize with flip) that is also in the whole view's coordinate system. and then change back to the "old" absolute frame of the cell (upon pressing button). I got the logic handled via buttons and delegates that is working fine. The only thing not working is the framing.

Any ideas?

I have tried to get the absolute frameInMainWindow but just cant get it right. and tried to play with clipToBounds with no luck. And a BUNCH of other stuff that did not help.

Does anybody out there have an idea of how to accomplish the above?

Any help would be greatly appreciated.

cell.contentView.contentMode = UIViewContentModeRedraw;
[UIView transitionWithView:cell.contentView duration:2
                   options:UIViewAnimationOptionTransitionFlipFromRight
                animations: ^{            
cell.contentView.frame = CGRectMake(0,
                                0,
                                myFullView.frame.size.width,
                               myFullView.frame.size.height);
                    [cell.contentView addSubview:myFullView];                     
                    [gmGridView bringSubviewToFront:cell];}
                completion: ^(BOOL finished) { }];

Solution

  • This will help you,

    CGRect theFrame = CGRectMake(0, 0, myFullView.frame.size.width, myFullView.frame.size.height);
    CGRect frameInSelfView = [self.view convertRect:theFrame fromView:cell];