以下代码实现了移动效果,但我没有使用
beginAnimations:context
。如何使其在不进行动画的情况下移动?这是一个新的iPhone视图项目,这些是对它唯一的更新。// 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];
}