move a CALayer (add animation)

well I have a CALayer layer and I would like to move it, with a CADisplaylink. Like :

layer.center=CGPointMake(layer.center.x + 10, layer.center.y + 10);

but I can't use center or position for the layer.Here is my problem, I want to make it move like it was a uiimageview.

Answers


To move layer try to use this method

-(void)moveLayer:(CALayer*)layer to:(CGPoint)point{
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
    animation.fromValue = [layer valueForKey:@"position"];
    animation.toValue = [NSValue valueWithCGPoint:point];
    layer.position = point;
    [layer addAnimation:animation forKey:@"position"];
}

Need Your Help

GNU screen custom key bindings format

key-bindings gnu-screen screenrc

I am trying to add key bindings to the .screenrc file for making a lot of things easier. So far I have understood the following pattern

Strategy to create multiple representations for the same class based on criteria using ROAR gem?

ruby-on-rails json rails-roar representable

This is actually a best practices / usage question on hwo to use Roar & representable in Rails, as I didn't find any examples of that. Here are two scenarios. I use decorator pattern.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.