gpt4 book ai didi

objective-c - 翻转、增长和翻译动画

转载 作者:可可西里 更新时间:2023-11-01 03:09:39 26 4
gpt4 key购买 nike

this video MLB At Bat 应用程序。基本上,我只想呈现一个具有 UIModalPresentationFormSheet 样式的 modalViewController 并让它从另一个 View 增长然后翻转。就像您在 MLB 应用程序的记分牌上点击一场比赛一样。任何人都知道我如何才能做到这一点?

谢谢

编辑:我的主视图与 MLB 应用程序的设置几乎相同。我正在使用 AQGridView 并希望在点击 GridView 中的单元格时出现动画。

编辑 2:我也愿意放弃 UIViewController 概念,只使用普通的 UIView,然后复制 UIModalPresentationFormSheet 的样式> 手动,如果这样更容易的话。

编辑 3:好的,忘记使用 UIViewController 来执行此操作,因为我没有收到任何回复,我假设这是不可能的。我的新问题是如何仅使用 UIView 复制已发布视频中的动画?所以基本上,初始 View 需要同时增长、移动和翻转。

编辑 4:我想我已经弄清楚了实际的动画,现在我唯一的问题是计算坐标以输入 CATransform3DTranslate。我的 View 需要像视频中一样进行动画处理。它需要重新开始另一个 View 并动画到屏幕的中心。以下是我尝试计算在中心弹出的 View 的坐标的方法:

CGPoint detailInitialPoint = [gridView convertPoint:view.frame.origin toView:detailView.frame.origin];
CGPoint detailFinalPoint = detailView.frame.origin;

gridView 是我的主视图的容器 View ,它包含较小的网格项。 view 是我们制作动画的特定网格项。 detailView 是出现在屏幕中间的 View 。

最佳答案

您可以使用 UIViewControler 上的类别实现您自己的转换。

UIViewController+ShowModalFromView.h

#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>

@interface UIViewController (ShowModalFromView)
- (void)presentModalViewController:(UIViewController *)modalViewController fromView:(UIView *)view;
@end

UIViewController+ShowModalFromView.m

#import "UIViewController+ShowModalFromView.h"

@implementation UIViewController (ShowModalFromView)

- (void)presentModalViewController:(UIViewController *)modalViewController fromView:(UIView *)view {
modalViewController.modalPresentationStyle = UIModalPresentationFormSheet;

// Add the modal viewController but don't animate it. We will handle the animation manually
[self presentModalViewController:modalViewController animated:NO];

// Remove the shadow. It causes weird artifacts while animating the view.
CGColorRef originalShadowColor = modalViewController.view.superview.layer.shadowColor;
modalViewController.view.superview.layer.shadowColor = [[UIColor clearColor] CGColor];

// Save the original size of the viewController's view
CGRect originalFrame = modalViewController.view.superview.frame;

// Set the frame to the one of the view we want to animate from
modalViewController.view.superview.frame = view.frame;

// Begin animation
[UIView animateWithDuration:1.0f
animations:^{
// Set the original frame back
modalViewController.view.superview.frame = originalFrame;
}
completion:^(BOOL finished) {
// Set the original shadow color back after the animation has finished
modalViewController.view.superview.layer.shadowColor = originalShadowColor;
}];
}

@end

这可以很容易地更改为使用您想要的任何动画过渡;对于您的,您可能想要使用 CA3DTransform。希望这对您有所帮助!

关于objective-c - 翻转、增长和翻译动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10038156/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com