内容简介:翻译自: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
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Windows核心编程(第5版)
Jeffrey Richter、Christophe Nasarre / 葛子昂、周靖、廖敏 / 清华大学出版社 / 2008-9 / 99.00元
这是一本经典的Windows核心编程指南,从第1版到第5版,引领着数十万程序员走入Windows开发阵营,培养了大批精英。. 作为Windows开发人员的必备参考,本书是为打算理解Windows的C和C++程序员精心设计的。第5版全面覆盖Windows XP,Windows Vista和Windows Server 2008中的170个新增函数和Windows特性。书中还讲解了Windows......一起来看看 《Windows核心编程(第5版)》 这本书的介绍吧!