IOS 7天气APP喜欢过渡/动画 [英] IOS 7 Weather APP Like Transition/Animations

查看:90
本文介绍了IOS 7天气APP喜欢过渡/动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现IOS Weather APP,如转换,ListView,点击它扩展到详细视图的列表项,或者捏到列表也扩展到详细视图。

I would like to implement IOS Weather APP like transition, ListView, tap on list item it expands to detail view, or pinch to list also expands to detail view.

向左和向右滑动过渡。请让我知道如何实现这一点。

Slide left and right transitions. Please let me know how can I implement that.

提前致谢。

推荐答案

以下是我发现的博客上的一些帖子,解释了Apple iOS 7上的新转换API,通过它,阅读它。

Here is some post on a blog I found that explains Apple new Transitioning API on iOS 7, go through it, read it.

简而言之,这里是步骤

1 - 在控制器上设置转换委托

1 - Set a transition delegate on a controller

您可能想要自定义3种类型的转换:

There are 3 types of transitions you might want to customise :


  • UINavigationController push&弹出过渡

  • UItabBarController 标签已更改过渡

  • 任何带有 presentViewController:动画

  • UINavigationController push & pop transitions
  • UItabBarController tab changed transitions
  • any modal presentation with presentViewController:animated

这3个案例中的每一个都提供了自己的转移委托协议:

Each of these 3 cases offers its own 'transition delegate' protocol :


  • UINavigationControllerDelegate

  • UITabBarControllerDelegate

  • UIViewControllerTransitioningDelegate

  • UINavigationControllerDelegate
  • UITabBarControllerDelegate
  • UIViewControllerTransitioningDelegate

当您从代码中的某个地方使用演示方法时:

When, from somewhere in your code, you use the methods for presentation :


  • pushViewController:animated: popViewControllerAnimated:

  • setViewControllers:animated:

  • presentViewController:动画

  • pushViewController:animated: or popViewControllerAnimated:
  • setViewControllers:animated:
  • presentViewController:animated

然后,如果需要动画,这些代表会询问我称之为'动画师'。

Then, these delegates asks for what I call an 'animator' if an animation is required.

我称之为动画师的是对象符合协议< UIViewControllerAnimatedTransitioning> (或< UIViewControllerInteractiveTransitioning> 以防交互转换,如手势驱动的交互)。这将动画与 UIViewControllers (可能已经包含大量代码)分离出来了。

What I'm calling an 'animator' is an object conforming to protocol <UIViewControllerAnimatedTransitioning> (or <UIViewControllerInteractiveTransitioning> in case of interactive transition, like gesture driven interactions). This decouples the animation from your UIViewControllers (which might already have plenty of code inside)

2 - 写'animator'

2 - Write the 'animator'

这是负责动画转换的对象。这可以是一个viewController,也可以是一个全新的NSObject。

This is the object responsible for animating transition. This can be a viewController, or a completely new NSObject.

如果是UINavigationController,你可以为推送和弹出操作定义不同的动画师。

In case of a UINavigationController, you could define different animators for push and pop operation.

3 - 将动画所需的属性添加到动画师中,然后对动画进行编码

3 - add the properties you need for your animation into your animator, and code the animation

'animator'可能会实现不同的协议,具体取决于您尝试自定义的转换。
如果是非交互式动画,则可以使用以下方法:

The 'animator' might implement different protocols, depending on which transition you're trying to customise. In case of non interactive animations, these are the methods :


  • - (NSTimeInterval )transitionDuration:(id< UIViewControllerContextTransitioning>)transitionContext :定义动画的持续时间

  • - (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext : define the duration of animation

- (void )animateTransition:(id< UIViewControllerContextTransitioning>)transitionContext 这是牛肉去的地方。请参阅上面链接中的示例代码,

- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext this is where the beef goes. See the example code in link above,

- (void)animationEnded:(BOOL)transitionCompleted for播放动画后的任何清理。

- (void)animationEnded:(BOOL)transitionCompleted for any clean-up after your animation was played.

在你的例如,你可能想在你的动画师类中添加一些'origin'和'target' UIView 属性(当然是弱属性!)

In your case, you might want to add some 'origin' and 'target' UIView properties in your animator class (as weak properties of course !)

然后,当您检测到用户点击了哪个视图时。 (在你的 UITableVIewDelegate UICollectionViewDelegate didSelect方法中),你告诉你的动画师它可以用THAT特定的帧动画,然后调用'push','pop'或'presentViewController',具体取决于你的导航逻辑。

Then, when you detect 'which' view was tapped by user. (in your UITableVIewDelegate or UICollectionViewDelegate didSelect methods), you tell your animator so that it can animate with THAT specific frame, then call the 'push', 'pop' or 'presentViewController' , depending on your navigation logic.

这篇关于IOS 7天气APP喜欢过渡/动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆