我如何启用隐式UIViewanimation?

试图把我的大脑围绕animation这里。 这是我的基本情况:

_________ |Parent | | | | | | _____ | _____ | |A | | |B | | |_____| | |_____| |_________| 

其中Parent是父视图, AB都是UIView实例。 我select制作AB UIView ,因为据我所知,图层不能接收用户交互。 我想要做的animation非常简单:我只想让A在屏幕左侧滑动,而B从右侧滑动。

我尝试了以下内容:

 CALayer *layer = viewA.layer; layer.position = CGPointMake(initialLayer.position.x, initialLayer.position.y - 480); 

但该属性立即更新,没有animation。

使用CABasicAnimation可以让我的工作没有太多麻烦,但是我想学习使用隐式animation来处理这种场景,所以我可以在未来更快地进行原型devise。 这个post似乎暗示, UIView不能执行隐式animation(至less默认)。

我的问题:

  1. 有没有一种方法隐式地在UIView的图层上animation的属性? 怎么样?
  2. 如果没有,是否有更好的/规范的方式来做到这一点,这是不同于我的方法?

你可以使用animateWithDuration

 [UIView animateWithDuration:2.0 animations:^{ viewA.frame = newFrame; }];