Ras*_*sto 1 animation cocoa-touch core-animation calayer ios
这让我很生气.每当我改变CATextLayer.foregroundColor属性值时,无论我做什么,变化都是动画的.例如,我已经CATextLayer调用了layer哪个子层CALayer superlayer:
layer.removeAllAnimations()
superlayer.removeAllAnimations()
superlayer.actions = ["sublayers" : NSNull()]
CATransaction.begin()
CATransaction.setAnimationDuration(0)
CATransaction.disableActions()
CATransaction.setValue(kCFBooleanTrue, forKey:kCATransactionDisableActions)
layer.actions = ["foregroundColor" : NSNull()]
layer.actions = ["content" : NSNull()]
layer.foregroundColor = layoutTheme.textColor.CGColor
CATransaction.commit()
Run Code Online (Sandbox Code Playgroud)
它仍然会动画!请帮忙,如何禁用隐式动画?
问题是CATransaction.disableActions()你不会做你认为它做的事情.你需要说CATransaction.setDisableActions(true).
然后你可以摆脱你所说的所有其他东西,因为它毫无意义.仅此代码足以在没有动画的情况下更改颜色:
CATransaction.setDisableActions(true)
layer.foregroundColor = UIColor.redColor().CGColor // or whatever
Run Code Online (Sandbox Code Playgroud)
(如果你有其他原因可以将它包装在begin()/ commit()block中,但是没有必要只是为了关闭隐式图层属性动画.)
| 归档时间: |
|
| 查看次数: |
870 次 |
| 最近记录: |