Animating using CALayer

26 views
Skip to first unread message

M. S. Hrishikesh

unread,
Jun 9, 2012, 7:32:56 AM6/9/12
to cocoa-...@googlegroups.com
Hi 

I am trying to learn core animation.

Note: I know how to use UIView Animations. This is a toy program to learn core animation.

I loaded a image into a UIImageView in my test application. I added a gesture recognizer to my image view that will let me drag the image around. When the image is placed inside a specific rectangular area I try to animate the image to the bottom of the screen.


I use the following code to try to animate the image when it is placed in the box. But it does not work. The image is merely moved to the bottom (not animated).


[CATransaction setAnimationDuration:5];
myImageView.layer.position = bottomPosition;

I have gone through the "Core animation essentials" video (2011 WWDC) and I think what I am doing is similar to that video. The only difference is that the tutorial uses an explicit CALayer while I am using the layer from a UIImageView.

But I don't get any animation. The image is just moved to the new location

What am I doing incorrectly?

Thanks
Hrishi

mattn

unread,
Jun 10, 2012, 10:58:56 AM6/10/12
to cocoa-...@googlegroups.com
The only difference is that the tutorial uses an explicit CALayer while I am using the layer from a UIImageView.


Correct. And that difference is the reason. You cannot use implicit property animation on a view's primary layer. 
Reply all
Reply to author
Forward
0 new messages