我有一个 CAShapeLayer,它必须完成一个简单的任务,即在用户手指的引导下在屏幕上移动。
问题是移动太慢了。该层确实移动,但有一个滞后,感觉很慢。
我有另一个测试应用程序,其中 UIImage 被移动并且完全没有滞后并且图像立即移动。
我能做些什么来克服这个问题?
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { currentPoint = [[touches anyObject] locationInView:self]; } - (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event { CGPoint activePoint = [[touches anyObject] locationInView:self]; CGPoint newPoint = CGPointMake(activePoint.x - currentPoint.x,activePoint.y - currentPoint.y); curLayer.position = CGPointMake(shapeLayer.position.x+newPoint.x,shapeLayer.position.y+newPoint.y); 当前点 = 活动点; }
谢谢!