【发布时间】:2023-07-16 21:30:01
【问题描述】:
我有一个 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);
当前点 = 活动点;
}
谢谢!
【问题讨论】:
标签: uikit core-animation quartz-graphics cgpath cashapelayer