CALayer、CAConstraint 和禁用动画
CALayer, CAConstraint & Disabling the Animation
我想知道是否有办法禁用特定图层的动画?
我这里的示例是一个沼泽标准 CALayer(NSView 的 CALayer)和一个子层 CATextLayer...
CAtextLayer 很好地绑定到 NSView 的 CALayer 并且完全按照它应该做的..所以那里没有问题...
如何在调整视图大小时关闭 "easing" 动画?
从字面上看,这就是我的 NSView 子类中的所有内容:
override func awakeFromNib() {
var newLayer: CALayer = CALayer()
newLayer.backgroundColor = NSColor.blackColor().CGColor
newLayer.layoutManager = CAConstraintLayoutManager.layoutManager()
self.layer = newLayer
self.wantsLayer = true
var textLayer: CATextLayer = CATextLayer()
newLayer.insertSublayer(textLayer, atIndex: 0)
textLayer.string = "Yay Layer"
textLayer.foregroundColor = NSColor.whiteColor().CGColor
textLayer.name = "textlayer"
textLayer.fontSize = 42.0;
textLayer.alignmentMode = kCAAlignmentCenter;
textLayer.addConstraint(CAConstraint(attribute: .MidX, relativeTo: "superlayer", attribute: .MidX, scale: 1.0, offset: 0.0))
textLayer.addConstraint(CAConstraint(attribute: .MaxY, relativeTo: "superlayer", attribute: .MaxY, scale: 1.0, offset: -50.0))
}
这是我得到的片段:
Screen Capture of Wobbly (eased) Constraints
我期望的是 textLayer 遵守约束,直到它被赋予动画师..
有什么方法可以阻止、删除或以其他方式阻止它吗?
干杯,
一个
textLayer.actions = ["position" : NSNull()]
我想知道是否有办法禁用特定图层的动画?
我这里的示例是一个沼泽标准 CALayer(NSView 的 CALayer)和一个子层 CATextLayer...
CAtextLayer 很好地绑定到 NSView 的 CALayer 并且完全按照它应该做的..所以那里没有问题...
如何在调整视图大小时关闭 "easing" 动画?
从字面上看,这就是我的 NSView 子类中的所有内容:
override func awakeFromNib() {
var newLayer: CALayer = CALayer()
newLayer.backgroundColor = NSColor.blackColor().CGColor
newLayer.layoutManager = CAConstraintLayoutManager.layoutManager()
self.layer = newLayer
self.wantsLayer = true
var textLayer: CATextLayer = CATextLayer()
newLayer.insertSublayer(textLayer, atIndex: 0)
textLayer.string = "Yay Layer"
textLayer.foregroundColor = NSColor.whiteColor().CGColor
textLayer.name = "textlayer"
textLayer.fontSize = 42.0;
textLayer.alignmentMode = kCAAlignmentCenter;
textLayer.addConstraint(CAConstraint(attribute: .MidX, relativeTo: "superlayer", attribute: .MidX, scale: 1.0, offset: 0.0))
textLayer.addConstraint(CAConstraint(attribute: .MaxY, relativeTo: "superlayer", attribute: .MaxY, scale: 1.0, offset: -50.0))
}
这是我得到的片段:
Screen Capture of Wobbly (eased) Constraints
我期望的是 textLayer 遵守约束,直到它被赋予动画师..
有什么方法可以阻止、删除或以其他方式阻止它吗?
干杯,
一个
textLayer.actions = ["position" : NSNull()]