在 Three20 中使用 CATransition?

发布于 2024-09-15 17:34:41 字数 730 浏览 5 评论 0原文

我希望在 TTNavigator 中实现 CATransitions,我知道该方法 openURL 可以采用 UIViewAnimationTransition 但这只给了我 翻转和卷曲动画,但通过 CATransition 我可以访问 到另外8个,其中kCATransitionFromRight,kCATransitionFromLeft, kCATransitionFromTop、kCATransitionFromBottom 是我的 特别是之后。

对于 UINavigationController 将使用类似这段代码的东西 让我更好地控制动画:

    CATransition *transition = [CATransition animation];
    transition.duration = 0.5f;
    transition.timingFunction = [CAMediaTimingFunction
    functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
    [self.navigationController.view.layer addAnimation:transition
    forKey:nil];

但是,此代码不适用于 TTNavigator。有谁知道吗 如何让我自己的自定义动画与 TTNavigator 一起使用?或者如果 我的代码做错了什么?

I am looking to implement CATransitions within TTNavigator, I know the method
openURL can take a UIViewAnimationTransition but that only gives me
flipping and curling animations, but with CATransition I have access
to another 8, of which kCATransitionFromRight, kCATransitionFromLeft,
kCATransitionFromTop, kCATransitionFromBottom are the ones I am
specifically after.

With a UINavigationController would use something like this piece of code to
give me more control over the animation:

    CATransition *transition = [CATransition animation];
    transition.duration = 0.5f;
    transition.timingFunction = [CAMediaTimingFunction
    functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
    [self.navigationController.view.layer addAnimation:transition
    forKey:nil];

This code however, doesn't work with TTNavigator. Does anybody know
how I can get my own custom animations to work with TTNavigator? Or if
I am doing something wrong in my code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

稚然 2024-09-22 17:34:42

结果我回答了我自己的问题,但我没有使用最后一行代码在 navigationController 上设置动画,而是尝试设置到 URLAction 的转换。一旦我把那行放回去并注释掉 URLAction 转换代码,它似乎就可以工作了!

    // create the URLAction
TTURLAction* urlAction;
urlAction = [TTURLAction actionWithURLPath:@"tt://Images"]; 
[urlAction applyAnimated:YES];

    // create the CATransition and set it to the navigation controller
CATransition *transition = [CATransition animation];
transition.duration = 0.5f;
transition.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
[self.navigationController.view.layer addAnimation:transition
forKey:nil]; 

    // tell the navigator to run the action
[[TTNavigator navigator] openURLAction:urlAction];

希望这对将来的其他人有帮助!

Turns out i answered my own question, but rather than using that last line of code to set the animation on the navigationController i was trying to set the transition to the URLAction. Once i put that line back in and commented out the URLAction transition code it seems to work!

    // create the URLAction
TTURLAction* urlAction;
urlAction = [TTURLAction actionWithURLPath:@"tt://Images"]; 
[urlAction applyAnimated:YES];

    // create the CATransition and set it to the navigation controller
CATransition *transition = [CATransition animation];
transition.duration = 0.5f;
transition.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
[self.navigationController.view.layer addAnimation:transition
forKey:nil]; 

    // tell the navigator to run the action
[[TTNavigator navigator] openURLAction:urlAction];

Hope this helps someone else in the future!

想你只要分分秒秒 2024-09-22 17:34:42

您可以使用 TTLauncherView 轻松地在 TTNavigator 上添加翻转或任何其他类型的动画,如下所示:

- (void)launcherView:(TTLauncherView*)launcher didSelectItem:(TTLauncherItem*)item {
    TTURLAction* action = [TTURLAction actionWithURLPath:item.URL];
    [action setAnimated:YES];
    [action setTransition:UIViewAnimationTransitionFlipFromLeft];
    [[TTNavigator navigator] openURLAction:action];
}

这使得 TTNavigator 在显示新 URL 时使用动画过渡。

You can easily add flip or any other kind of animation on TTNavigator using TTLauncherView as follows:

- (void)launcherView:(TTLauncherView*)launcher didSelectItem:(TTLauncherItem*)item {
    TTURLAction* action = [TTURLAction actionWithURLPath:item.URL];
    [action setAnimated:YES];
    [action setTransition:UIViewAnimationTransitionFlipFromLeft];
    [[TTNavigator navigator] openURLAction:action];
}

This makes TTNavigator use animated transition while displaying new URL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文