CALayer, CAConstraint & Disabling the Animation
I was wondering if there's a way to disable the animations for particular layer?
My example here is a bog standard CALayer (the NSView's CALayer), and a sublayer, CATextLayer...
CAtextLayer is nicely tethered to the NSView's CALayer and does exactly what it should.. So no issues there...
how do I turn off the "easing" animations when the view is resized?
Literally this is all I have in my NSView subclass:
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))
}
Here's a clip of what I'm getting:
Screen Capture of Wobbly (eased) Constraints
What I expected was for the textLayer to adhere to the constraints until it was otherwise given an animator..
Is there any way to stop, remove, or otherwise stop it?
Cheers,
A
textLayer.actions = ["position" : NSNull()]
链接地址: http://www.djcxy.com/p/74200.html