calayer

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

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

AVCaptureSession captured photo's size different than the preview?

China☆狼群 提交于 2020-06-17 15:58:26
问题 These two images are the camera preview and the resulting capture (in that order, respectively [taken via screenshots]). We want the captured photo to match the preview/vice versa. How can we address this? Tried manipulating the CALayer containing the photo data to size the image like how a Xamarin.Forms' image sizes with AspectFit by assigning the ContentsGravity with various options like kCAGravityResizeAspect . Fiddled with other Contents options such as ContentsRect and ContentsScale but

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?

AVFoundation: Fit Video to CALayer correctly when exporting

徘徊边缘 提交于 2020-05-28 03:29:32
问题 Problem: I'm having issues getting videos I'm creating with AVFoundation to show in the VideoLayer, a CALayer , with correct dimensions. Example: Here is what the video should look like (as its displayed to the user in the app) However, here's the resulting video when it's exported: Details As you can see, its meant to be a square video, with green background, with the video fitting to a specified frame. However, the resulting video doesn't fit the CALayer used to contain it (see the black

iOS开发CoreAnimation解读之四——Layer层动画内容

六月ゝ 毕业季﹏ 提交于 2020-04-10 07:46:12
iOS开发CoreAnimation解读之四——Layer层动画内容 一、引言 通过前几篇博客的介绍,我们可以了解到layer层可以设置许多与控件UI相关的属性,并且对于iOS开发,UIView层的属性是会映射到CALayer的,因此,可以通过UIKit和CoreAnimation两个框架来设置控件的UI相关属性,当属性发生变化时,我们可以使其展示一个动画效果。 二、CAAnimation动画体系的介绍 CAAnimation是CoreAnimation框架中执行动画对象的基类,下面有一张图,是我手画的,不太美观,但是可以将与CAAnimation相关的几个动画类的关系表达清楚: 从上图中可以看到,从CAAnimation中继承出三个子类,分别是用于创建属性动画的CAPropertyAnimation,创建转场动画的CATransition和创建组合动画的CAAnimationGroup。 我们就先从根类开始探讨。 1.CAAnimation属性和方法 CAAnimation作为动画对象的基类,其中封装了动画的基础属性,如下: //通过类方法创建一个CAAnimation对象 + (instancetype)animation; //动画执行的时序模式 @property(nullable, strong) CAMediaTimingFunction *timingFunction

iOS开发CoreAnimation解读之一——初识CoreAnimation核心动画编程

[亡魂溺海] 提交于 2020-04-10 00:06:52
iOS开发CoreAnimation解读之一——初识CoreAnimation核心动画编程 一、引言 众所周知,绚丽动画效果是iOS系统的一大特点,通过UIView层封装的动画,基本已经可以满足我们应用开发的所有需求,但若需要更加自由的控制动画的展示,我们就需要使用CoreAnimation框架中的一些类与方法。这里先附上前几篇与动画相关的博客地址,这一系列,我们抽出其中的CoreAnimation框架来详细解读。 UIViewAnimation动画的使用: http://my.oschina.net/u/2340880/blog/484457 UIView动画执行的另一种方式: http://my.oschina.net/u/2340880/blog/484538 UIView转场动画: http://my.oschina.net/u/2340880/blog/484669 CoreAnimation隐式动画的应用: http://my.oschina.net/u/2340880/blog/484793 粒子效果的使用: http://my.oschina.net/u/2340880/blog/485095 二、初识CoreAnimation CoreAnimation框架是基于OpenGL与CoreGraphics图像处理框架的一个跨平台的动画框架。简单来说

Swift - UI Button Shadow Gradient

筅森魡賤 提交于 2020-04-07 16:52:37
问题 I am trying to recreate a button like this in Swift: I have been able to create the gradient inside of the button accurately from Sketch using the help from here: Answered Question Now I am trying to recreate the glow effect behind the button. I was thinking creating a subview behind it and using a gaussian blur filter to draw it. Now I am stuck in how to implement this, and haven't found a good solution. The normal CALayer shadow doesn't work with gradients, and I am lost. Any help is