core-animation

What exactly does removedOnCompletion = NO do?

試著忘記壹切 提交于 2019-12-03 06:01:17
问题 CAAnimation provides the removedOnCompletion property which defaults to YES. Let's recognize these facts: A) Core Animation only affects the Presentation Tree, but not the Model Tree. When an animation is done, you end up seeing whatever is set in the Model Tree. You can set a fillMode to kCAFillModeBoth for example, which will swap the value from the Presentation Tree over to the Model Tree once the animation is done. This causes your animation to not revert back (which is most likely what

Masking a CALayer with another CALayer

旧街凉风 提交于 2019-12-03 05:25:36
I'm trying to make a donut shape with CALayers. One CALayer will be a large circle, the other one will be a smaller circle positioned in its center, masking it. The large circle displays fine, but whenever I call circle.mask = circleMask; then the view appears empty. Here's my code: AriDonut.h #import <UIKit/UIKit.h> @interface AriDonut : UIView -(id)initWithRadius:(float)radius; @end AriDonut.m #import "AriDonut.h" #import <QuartzCore/QuartzCore.h> @implementation AriDonut -(id)initWithRadius:(float)radius{ self = [super initWithFrame:CGRectMake(0, 0, radius, radius)]; if(self){ //LARGE

Recreate Siri Button Glow Animation

空扰寡人 提交于 2019-12-03 05:23:43
问题 Is there any way of duplication the siri button glow animation? It looks absolutely gorgeous, but I have no idea at the moment how to start... are there online preformatted pngs that are rotated? or is it done with CoreAnimation? 回答1: I believe that Siri animation is made with CAEmitterLayer and CAEmitterCell and then animated with core animation, but I might be totally wrong. Here's some code that imitates the effect: // create emitter layer self.emitterLayer = [CAEmitterLayer layer]; self

UIView beginAnimations with subviews

帅比萌擦擦* 提交于 2019-12-03 05:18:09
问题 I have a nice and easy "zoom" animation for a view, which starts as a dot and animates up to full screen size: [UIView beginAnimations:nil context:NULL]; [UIView setAnimationBeginsFromCurrentState:YES]; [UIView setAnimationDuration:1.0]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; myView.frame = CGRectMake(0,0,320,480); myView.transform = CGAffineTransformIdentity; [UIView commitAnimations]; So far so good :-) The problem is that when I add subviews to myView, to my surprise,

How to animate while resizing UIView

江枫思渺然 提交于 2019-12-03 05:13:42
问题 I saw some material on the web, but still can't quite get to where I want. I need to animate my view downwards, making it's height bigger. Here is my code so far. What's happening here, is that instead of my view resizing, it's just changing it's location a bit up. If I change the proprty instead of "bounds.size" to be "transform.scale.y", it's a little better, only this time it expands the view both up and down, not just downwards. Another thing I'm not of : are these keys just CALayer

CALayer opacity animation

南楼画角 提交于 2019-12-03 04:55:26
I want to create a CALayer animation that gives sort of a 'flashy' effect. For that I'm trying to animate the 'opacity' property, but my problem is that I have no idea where to start and how to do it. Here is a graphical explanation of the animation: opacity | ___ 1 | | | | | | * repeatCount 0 |___| |_ . . . -------------------------> time |______| duration The opacity starts at 0, then animates to 1, then to 0 again (this 0-to-1-to-0 animation takes a number of seconds equal to duration). Then this process is repeated 'repeatCount' times. Here's some background on the code: float duration = .

How exactly to subclass CALayer and use a custom property?

喜欢而已 提交于 2019-12-03 04:44:27
问题 I am trying to create a subclass of CALayer with a custom index property that I can both animate and change directly in order to display a different picture based on the index. In the header, I declared: @property NSUInteger index; In the implementation, I overrode needDisplayForKey : + (BOOL)needsDisplayForKey:(NSString *)key { if ([key isEqualToString:@"index"]) return YES; else return [super needsDisplayForKey:key]; } Now, in the display method, I want to display a picture based on the

Interpolating values between interval, interpolation as per Bezier curve

旧巷老猫 提交于 2019-12-03 04:42:25
To implement a 2D animation I am looking for interpolating values between two key frames with the velocity of change defined by a Bezier curve. The problem is Bezier curve is represented in parametric form whereas requirement is to be able to evaluate the value for a particular time. To elaborate, lets say the value of 10 and 40 is to be interpolated across 4 seconds with the value changing not constantly but as defined by a bezier curve represented as 0,0 0.2,0.3 0.5,0.5 1,1. Now if I am drawing at 24 frames per second, I need to evaluate the value for every frame. How can I do this ? I

How to work around poor text rendering in text backed by a CALayer

瘦欲@ 提交于 2019-12-03 04:34:54
问题 I have some variable text in an NSTextField that renders on a CALayer background view. As a CALayer does not support sub-pixel aliasing for text rendering of any text on top of it, this text looks rubbish. A bit of googling reveals the reasons why this is, and that text must be rendered onto an opaque background to have SPA enabled. Rendering onto an opaque background is something I'd like to avoid if at all possible in this case. Is there a better workaround? I am completely amenable to

Setting up AVSynchonizedLayer

ⅰ亾dé卋堺 提交于 2019-12-03 04:32:34
问题 I've been trying to produce a proof of concept that connects a video with an animation object (essentially, I am "rotoscoping" a user-selected-bitmap onto a canned video at specific locations). After watching all the available Apple material regarding Core Animation (WWDC10, etc.) and the AVSync..Layer (Apple WWDC10 sample code, doc sample code), there simply isn't a clear enough isolated code example to derive how to implemented this playback mode correctly. Using CA, I have a video asset