core-animation

Observing animated property changes in a CALayer

落爺英雄遲暮 提交于 2020-07-31 07:55:06
问题 I have a CABasicAnimation that animating a property of a CALayer e.g. bounds.origin . I want to be able to observe the property changing over time, but haven't really found a method that works 100%. I tried using KVO (key-value observation) on the presentationLayer 's bounds.origin keypath. The system complains that the object is freed before its observers are freed, leading me to think that the presentation layer is only temporary. Observing presentationLayer.bounds.origin as a keypath doesn

CALayer delegate methods not called on layer hosted view

徘徊边缘 提交于 2020-07-22 22:20:56
问题 I have this layer hosted view, which is initialised like so: // Init layers self.wantsLayer = YES; _hostedLayer = [CALayer layer]; _hostedLayer.delegate = self; self.layer = _hostedLayer; Weirdly, the delegate method updateLayer is not called. When I comment out the last 3 lines, it does get called. What's wrong here? Hint: Yes I have overridden wantsUpdateLayer and return YES . 回答1: When a view asks for a layer it gets a special, private subclass of CALayer by default, which has extra

CALayer delegate methods not called on layer hosted view

坚强是说给别人听的谎言 提交于 2020-07-22 22:14:17
问题 I have this layer hosted view, which is initialised like so: // Init layers self.wantsLayer = YES; _hostedLayer = [CALayer layer]; _hostedLayer.delegate = self; self.layer = _hostedLayer; Weirdly, the delegate method updateLayer is not called. When I comment out the last 3 lines, it does get called. What's wrong here? Hint: Yes I have overridden wantsUpdateLayer and return YES . 回答1: When a view asks for a layer it gets a special, private subclass of CALayer by default, which has extra

Resizing MTKView scales old content before redraw

淺唱寂寞╮ 提交于 2020-07-18 06:38:07
问题 I'm using a MTKView to draw Metal content. It's configured as follows: mtkView = MTKView(frame: self.view.frame, device: device) mtkView.colorPixelFormat = .bgra8Unorm mtkView.delegate=self mtkView.sampleCount=4 mtkView.isPaused=true mtkView.enableSetNeedsDisplay=true setFrameSize is overriden to trigger a redisplay. Whenever the view resizes it scales its old content before it redraws everything. This gives a jittering feeling. I tried setting the contentGravity property of the MTKView's

Resizing MTKView scales old content before redraw

自作多情 提交于 2020-07-18 06:38:05
问题 I'm using a MTKView to draw Metal content. It's configured as follows: mtkView = MTKView(frame: self.view.frame, device: device) mtkView.colorPixelFormat = .bgra8Unorm mtkView.delegate=self mtkView.sampleCount=4 mtkView.isPaused=true mtkView.enableSetNeedsDisplay=true setFrameSize is overriden to trigger a redisplay. Whenever the view resizes it scales its old content before it redraws everything. This gives a jittering feeling. I tried setting the contentGravity property of the MTKView's

Comprehend pause and resume animation on a layer

孤街浪徒 提交于 2020-06-24 05:10:08
问题 I am studying Animation in Core Animation Programming Guide and I get stuck on comprehending pause and resume animation on a layer. The document tells me how to pause and resume animation without clear explanation. I think the key is to understand what is timeOffset and beginTime method of CAlayer . These code is pause and resume animation. In resumeLayer method, layer.beginTime = timeSincePause; this line really make me confused. -(void)pauseLayer:(CALayer*)layer { CFTimeInterval pausedTime

Comprehend pause and resume animation on a layer

若如初见. 提交于 2020-06-24 05:10:06
问题 I am studying Animation in Core Animation Programming Guide and I get stuck on comprehending pause and resume animation on a layer. The document tells me how to pause and resume animation without clear explanation. I think the key is to understand what is timeOffset and beginTime method of CAlayer . These code is pause and resume animation. In resumeLayer method, layer.beginTime = timeSincePause; this line really make me confused. -(void)pauseLayer:(CALayer*)layer { CFTimeInterval pausedTime

Layer backed NSView with custom CALayer not calling updateLayer?

柔情痞子 提交于 2020-06-10 02:41:37
问题 I have a custom layer-backed NSView and have overidden the makeBackingLayer method to return a custom CALayer subclass. I have also overriden wantsUpdateLayer to return true thereby fully opting into layer-like drawing. override func makeBackingLayer() -> CALayer { return Layer() // my custom class with "drawLayer:" implemented } override var wantsUpdateLayer:Bool{ return true } // never called override func updateLayer() { super.updateLayer() println("updateLayer after") self.layer?

Layer backed NSView with custom CALayer not calling updateLayer?

独自空忆成欢 提交于 2020-06-10 02:41:28
问题 I have a custom layer-backed NSView and have overidden the makeBackingLayer method to return a custom CALayer subclass. I have also overriden wantsUpdateLayer to return true thereby fully opting into layer-like drawing. override func makeBackingLayer() -> CALayer { return Layer() // my custom class with "drawLayer:" implemented } override var wantsUpdateLayer:Bool{ return true } // never called override func updateLayer() { super.updateLayer() println("updateLayer after") self.layer?