这是我目前拥有的:http://cl.ly/PIFB
及其背后的代码:
UIView *smallView = [[_tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:recognizer.view.tag inSection:0]] contentView];
CGRect initialSize = smallView.frame;
CGRect finalSize = CGRectMake(150.0, 100.0, 660.0, 450.0);
UIView *largeView = [[UIView alloc] initWithFrame:initialSize];
[largeView setBackgroundColor:[UIColor blackColor]];
[largeView setClipsToBounds:NO];
[UIView transitionFromView:smallView toView:largeView duration:2 options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) {
[[_tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:recognizer.view.tag inSection:0]] contentView].frame = finalSize;
[largeView setFrame:finalSize];
[smallView removeFromSuperview];
[self addSubview:largeView];
[UIView animateWithDuration:2 animations:^{
smallView.frame = finalSize;
[largeView setFrame:finalSize];
}];
}];
基本上我有一个 UITableView View 。当点击其中一个 View 时,我想同时缩放和翻转它,以便它在屏幕中央显示一个新的更大 View 。目前,它会翻转较小的 View ,并最终以正确的尺寸显示较大的 View ,但过渡不顺畅。
在上面的代码中,smallView 是当前点击的单元格内容 View 。 largeView 是最终将开发的新 View ,用于显示与被点击的单元格相关的更多数据。现在它由黑色 View 表示。我真的希望小细胞同时生长和翻转,以便它顺利过渡到更大的 View 。
我们将非常感谢您的帮助。我对 Objective C、cocoa touch 和执行动画的经验非常有限。
非常感谢。
最佳答案
我终于明白了。看这里:http://cl.ly/PQqP
它要求我执行两个单独的 UIViewtransitionWithView 方法:
[_transitionView addSubview:smallView];
[smallView setFrame:CGRectMake(0, 0, _transitionView.frame.size.width, _transitionView.frame.size.height)];
[UIView transitionWithView:_transitionView duration:.5 options:UIViewAnimationOptionTransitionFlipFromRight | UIViewAnimationOptionLayoutSubviews | UIViewAnimationOptionCurveEaseOut animations:^(){
[UIView transitionWithView:cellView duration:.25 options:UIViewAnimationOptionTransitionFlipFromRight | UIViewAnimationOptionLayoutSubviews | UIViewAnimationOptionCurveEaseIn animations:^(){
[cellView setFrame:smallViewOrigin];
} completion:NULL];
_transitionView.frame = finalSize;
smallView.frame = smallViewOrigin;
[_transitionView insertSubview:metricModalViewController.view belowSubview:smallView];
[smallView removeFromSuperview];
metricModalViewController.view.frame = metricModalEndSize;
} completion:^(BOOL finished) {
[_transitionView setFinalView:metricModalViewController.view];;
}];
关于iphone - 我想在缩放到新 View 时使用 UIViewAnimationOptionTransitionFlipFromRight,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16821409/