内容简介:翻译自:https://stackoverflow.com/questions/2930166/disable-animation-when-moving-calayers
以下代码为动作设置动画,即使我没有使用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]; }
最简单的方法是通过将位置代码放入事务来覆盖动画持续时间:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { [CATransaction begin]; [CATransaction setAnimationDuration:0]; sublayer.position = [[touches anyObject] locationInView:self.view]; [CATransaction commit]; }
翻译自:https://stackoverflow.com/questions/2930166/disable-animation-when-moving-calayers
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- 如何临时或永久地禁用SELinux
- 当浏览器全面禁用三方 Cookie
- Bootstrap禁用响应式布局的实现方法
- 如何绕过PHP中被禁用的函数
- php – 禁用表单元素的POST值
- Firefox 将在今年默认禁用 Flash
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Ant Colony Optimization
Marco Dorigo、Thomas Stützle / A Bradford Book / 2004-6-4 / USD 45.00
The complex social behaviors of ants have been much studied by science, and computer scientists are now finding that these behavior patterns can provide models for solving difficult combinatorial opti......一起来看看 《Ant Colony Optimization》 这本书的介绍吧!