开发者

Alternative to CGAffineTransformConcat

In the app I'm working on the user taps on a tableview to zoom it up to full view from a "thumbnail" or a miniature view. Everything is working great except for a somewhat annoying animation glitch or whatever. The thing is I'm using the code below:

    if ([subview respondsToSelector:@selector (name)] && [subview.name isEqualToString:self.labelListName.text]) 
    {
        [self.tabBarController.view addSubview:subview];
        CGRect frame = CGRectMake(35, 78, self.scrollView.frame.size.width, self.scrollView.frame.size.height);         
        subview.frame = frame;

        CGAffineTransform scale = CGAffineTransformMakeScale(1.39, 1.39);
        CGAffineTransform move = CGAffineTransformMakeTranslation(0,44);
        CGAffineTransform transform = CGAffineTransformConcat(scale, move);
        [UIView animateWithDuration:0.15
                              delay:0 
                            options:UIViewAnimationOptionBeginFromCurrentState 
                         animations:^{
                             subview.transform = transform;
                         } 
                         completion:^(BOOL finished){ [self goToList],subview.hidden = YES; }]; 
    }

- (void)goToList
{
    self.gotoWishList = [[WishList alloc] initWithNibName:@"WishList" bundle:nil];
    self.gotoWishList.hidesBottomBarWhenPushed=YES;
    s开发者_如何学编程elf.gotoWishList.name = self.labelListName.text;
    [self.navigationController pushViewController:self.gotoWishList animated:NO];
    self.gotoWishList.scrollLists = self;
    [WishList release];
}

And when doing the animation the transfer between the zoom view and the actual view the user is going to interact with is not completely perfect. The text inside the cell jumps a little when switching between the views. The problem lies in the translation matrix. If I skip that I can get the animation to work perfectly but then of course I need to move the miniature view down in the GUI which is not an option. If I instead do the animations in another order (move, scale) then it works better. I still get a jump at the end but it looks better, as everything jumps...and not just the text.

So...basically my question is how can I make this animation fluent. I read that the CGAffineTransformConcat still does each animation separately, and I really need both animations (scaling and moving the list) to be ONE fluent animation.

Thanks for any tips!


I think you will have to nest views/graphic-context to get what you want. The animation system doesn't support simultaneous animations because the mathematics of doing so requires an exponential amount of computational power. You might be able to trick it by sliding one view while enlarging the other.

I'm not sure about that as I have never had need to try it.

You might also be getting a jerk or skip from the tableview itself. The bounce at the top and end of scrolls can produce effects if you radically resize the table on the fly. I would turn all that off and see if you still have the problem. You might also want to test on the view independent of the tableview to make sure the problem is with the animations and not the tableview moving itself.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜