Trouble with UIView, animateWithDuration and finis

2019-07-07 01:45发布

I don't know what's wrong with this piece of code.

[UIView animateWithDuration:10.0f delay:0.0f options:UIViewAnimationOptionTransitionNone animations:^{
    CGAffineTransform transform = CGAffineTransformMakeScale(0.1, 0.1);
    self.transform = transform;
}
completion:^(BOOL finished) {
    if (finished) { 
        NSLog(@"Animation finished");
        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"NSShowHomeScreen" object:nil ];
    }
}];

Even with a 10 second duration, I get the console message "Animation finished" immediately as the animation starts.

I want to shrink / scale my first UIView and after that I'd like to show another UIView. But now the 2nd UIView gets displayed well before the shrink ends.

Any help would be greatly appreciated.

Thanks

2条回答
在下西门庆
2楼-- · 2019-07-07 02:35

Sorry it was my bad. I was also using UIPinchGestureRecognizer which was causing the problems. Anyway appreciate your quick reply..

Thanks

查看更多
放我归山
3楼-- · 2019-07-07 02:39

In the UIView documentation, for the transform property, says:

Changes to this property can be animated. Use the beginAnimations:context: class method to begin and the commitAnimations class method to end an animation block. The default is whatever the center value is (or anchor point if changed)

so maybe it cant be animated using the block methods, and you will have to use begin and commit wrappers around the animation

查看更多
登录 后发表回答