Disable animation when moving CALayers

Posted by Sean Clark Hess on Stack Overflow See other posts from Stack Overflow or by Sean Clark Hess
Published on 2010-05-28T15:10:45Z Indexed on 2010/05/28 15:12 UTC
Read the original article Hit count: 274

The following code animates the movement, even though I didn't use beginAnimations:context. How do I get it to move without animating? This is a new iphone view project, and these are the only updates to it.

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];

    sublayer = [CALayer new];
    sublayer.backgroundColor = [[UIColor redColor] CGColor];
    sublayer.frame = CGRectMake(0, 0, 100, 100);

    [self.view.layer addSublayer:sublayer];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    sublayer.position = [[touches anyObject] locationInView:self.view];
}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c