ios calayer

ios - CALayer anima con cambio de cuadro?



(2)

En Swift 4:

CATransaction.begin() CATransaction.setDisableActions(true) /* Your layer / frame changes here */ CATransaction.commit()

Tengo un CALayer que he agregado a mi vista:

myView.myCALayer = [[CALayer alloc] init]; CGSize size = myView.frame.size; myView.myCALayer.frame = CGRectMake(0, 0, size.width, size.height); myView.myCALayer.backgroundColor = [[UIColor blackColor] CGColor]; [myView.layer addSublayer:myView.myCALayer];

Cuando intento cambiar el marco del CALayer después de cambiar el marco de myView, se anima el cambio de tamaño del CALayer. No he agregado ninguna animación al CALayer, así que no entiendo esto. Incluso he intentado llamar a removeAllAnimations en la capa antes del cambio de tamaño y todavía anima el cambio de tamaño.

¿Alguien sabe que podría estar pasando aquí?


En realidad, hay una animación implícita en la configuración de algunos valores para un CALayer. Tiene que deshabilitar las animaciones antes de establecer un nuevo marco.

[CATransaction begin]; [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; [myView.myCALayer.frame = (CGRect){ { 10, 10 }, { 100, 100 } ]; [CATransaction commit];

https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CoreAnimation_guide/AdvancedAnimationTricks/AdvancedAnimationTricks.html#//apple_ref/doc/uid/TP40004514-CH8-SW3