使用平移手势移动CALayer时延迟
我使用平移手势在CALayer中移动图像。 我遇到的问题是,图像似乎移动了一点点延迟,并没有出现“卡住”我的手指。
这里是我如何移动图层的实际片段(facePic是CALayer):
CGPoint translation =[touche locationInView:self.view]; self.facePic.frame = CGRectMake(translation.x - self.facePic.frame.size.width/2, translation.y - self.facePic.frame.size.height/2, self.facePic.frame.size.width, self.facePic.frame.size.height);
我想你会看到一个图层隐式animation的结果。 如果是这样,那么有两个选项来禁用这个animation:
- 使用交易
- 设置图层操作
使用事务包装您的代码与CATransaction
[CATransaction begin]; [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; . . . [CATransaction commit];
要禁用某些图层操作,可以将其添加到图层init,位置animation例如:
aLayer.actions = @{@"position":[NSNull null]}; // FIXED property name
- 如何检测由CATransaction触发的animation的完成?
- CATransform3DROTATE与m34参数需要知道angular度以适应特定的高度
- 自定义视图与CALayer的有线效果,当animation边界改变
- 用UILabel文本掩码显示UIView
- 掩盖CAShapeLayer创build这个奇怪的神器?
- 如何禁用CALayer隐式animation?
- 与CALayers CAAnimation偶尔创build闪烁的animation(包括video)
- 在向后播放CABasicAnimation后,CALayer消失
- setNeedsDisplay,drawRect或CALayer导致dispatch_continuation_alloc_from_heap malloc内存泄漏iOS