我有以下代码来创建翻转过渡。 fromView
不会对变换设置动画并跳转到最终值,但toView
会正确设置变换动画。这可能有什么问题?
toView.hidden = NO;
toView.transform = CGAffineTransformMake(0, 0, 0, 1, 0, 0);
[UIView animateWithDuration:0.4
animations:^{
fromView.transform = CGAffineTransformMake(0, 0, 0, 1, 0, 0);
}
completion:^(BOOL finished) {
fromView.hidden = YES;
fromView.transform = CGAffineTransformIdentity;
[UIView animateWithDuration:0.4
animations:^{
toView.transform = CGAffineTransformMake(1, 0, 0, 1, 0, 0);
}
completion:nil];
}];
答案 0 :(得分:3)
由于转换矩阵中除以零问题,我不认为比例可以设置为0值。
查看此链接。 http://www.wenda.io/questions/217747/uiview-scale-to-0-using-cgaffinetransformmakescale.html
这是CGAffineTransformMakeScale animation not working
您可以改为使用较小的值进行缩放,然后隐藏视图,如下所示
[UIView animateWithDuration:0.4
animations:^{
fromView.transform = CGAffineTransformMakeScale(0.01, 1);
}
completion:^(BOOL finished) {
fromView.hidden = YES;
fromView.transform = CGAffineTransformIdentity;
[UIView animateWithDuration:0.4
animations:^{
toView.transform = CGAffineTransformMakeScale(1, 1);
}
completion:nil];
}];