core-animation

Why does this CAKeyFrameAnimation stop with zero opacity?

蹲街弑〆低调 提交于 2019-12-08 02:26:55
问题 I have this code. At the end of the values array, you can see I provide 0.5 for the opacity. But for some reason, when the animation stops, it flashes once again and then leaves the view completely transparent. What's wrong there? CALayer *layer = self.layer; CAKeyframeAnimation *blinkAnim = [CAKeyframeAnimation animationWithKeyPath:@"opacity"]; blinkAnim.duration = 1.0; //blinkAnim.repeatCount = 0; blinkAnim.autoreverses = NO; // keyframe times and values // we want to start fully opaque,

What is the best way to wait for a loop of UIView animations to finish?

拜拜、爱过 提交于 2019-12-08 01:06:29
问题 I'm trying to loop over multiple UIViews and perform animation on each, but I'd like to know when all of the animations have finished. What is the best way to call a function when the loop of animations has finished? Alternately, is there a way to wait until all have finished? I tried using setAnimationDidStopSelector , but it doesn't fire. In this case, I'm clearing some "chips" off a game board by having them fade out then get removed (NumberedChipView is a subclass of UIView). Play cannot

Does Core Animation provide public APIs for iBook style page curl page transitions?

独自空忆成欢 提交于 2019-12-08 00:51:28
问题 Does Core Animation provide public APIs for iBook style page curl page transitions? I have seen this blog post which is an almost exact re-engineering of iBook page-curl transitions but it relies on private APIs. Is there in fact a public version and if not is there something in open source? 回答1: Check the answer for Flipboard or iBooks style animation the code is available @ GitHub. 回答2: If you want to roll your own solution with OpenGL ES, I've written an introduction to simulating a page

Blur CALayer's Superlayer

[亡魂溺海] 提交于 2019-12-07 23:56:16
问题 I've got a CALayer and a sublayer in it. What i want to achieve is a blur of the superlayer (the area under the sublayer), just like the standard sheets do it. I've tried to set a .compositingFilter on the sublayer but this doesn't seem to work. Any ideas how to solve this? Code from the sublayers init: CIFilter *blur = [CIFilter filterWithName:@"CIGaussianBlur"]; [blur setDefaults]; self.layer.backgroundFilters = [NSArray arrayWithObject:blur]; 回答1: The above should work fine, depending on

Troubles with UIView, animateWithDuration and beginFromCurrentState

假装没事ソ 提交于 2019-12-07 21:44:41
问题 I have a custom view that has to track the user's location. I put the following code in touchesBegan , as well as in touchesMoved : [UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{ cursorView.center = locationOfTouch; } completion:^(BOOL finished){}]; It seems fairly straightforward to me. I'd expect the view to always animate to the user's current location, even if that location is changed and the view is still animating (because of

How to make image spin (animation)

故事扮演 提交于 2019-12-07 20:58:53
问题 I have an image which is a square and I know how to make it spin. But not sure how to make it spin exactly like this animation here: Notice how it spins... then stops a little... then spins again... and so on. What I have just is a basic spin but doesn't look like the gif above: extension UIView { func rotate360Degrees(duration: CFTimeInterval = 3) { let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation") rotateAnimation.fromValue = 0.0 rotateAnimation.toValue = CGFloat(M_PI * 2

Core Animation implicit animation doesn't fire for newly added sublayer

一笑奈何 提交于 2019-12-07 19:32:28
Don't know why this doesn't work. I can't do implicit animation for a newly added sublayer until some even triggers it like a button push or being called from another method. This here below doesn't animate even though I think i should. It just shows the 'after' state of the layer. CAGradientLayer *newBar = [CAGradientLayer layer]; CGFloat barHeight = ((pair.amount.floatValue/self.model.maxModelValue.floatValue)*maxBarHeight); newBar.bounds=R(0,0,self.barWidth,0); newBar.anchorPoint=P(0, 1); newBar.position=P((i*barSpacing), self.insideLayer.bounds.size.height); newBar.backgroundColor=self

Core Animation animating an array of images

旧时模样 提交于 2019-12-07 19:21:34
问题 What I basically want to do is tp display a sequence of images at a fast rate (60/second) in order to create a sequence. I'm going to create a timer and see if it's fast enough. I want to display an array of images in my cocoa app using an animation (up to 60 per seconds). Here's the animation I've created so far: - (CAAnimation*)imageAnimation; { CGImageRef image1 = [self nsImageToCGImageRef:[NSImage imageNamed:@"1.png"]]; CGImageRef image2 = [self nsImageToCGImageRef:[NSImage imageNamed:@"2

Draggable CALayer

本小妞迷上赌 提交于 2019-12-07 17:58:44
问题 Any way of making a CALayer draggable by the user? If so, how? (In Cocoa - Mac) 回答1: Layers can not receive mouse events themselves. You would have to do the event handling in the view or view controller containing the layer. If a mouseDragged: event originates on a layer (see -[CALayer hitTest:] and -[CALayer containsPoint:] to test this), adjust the layer's position accordingly. You will probably want to disable implicit animations to have the layer follow the mouse pointer immediately

How can I chain animations in iPhone-OS?

我只是一个虾纸丫 提交于 2019-12-07 17:10:28
问题 I want to do some sophisticated animations. But I only know how to animate a block of changes. Is there a way to chain animations, so that I could for example make changes A -> B -> C -> D -> E -> F (and so on), while the core-animation waits until each animation has finished and then proceeds to the next one? In particular, I want to do this: I have an UIImageView that shows a cube. Phase 1) Cube is flat on the floor Phase 2) Cube rotates slightly to left, while the rotation origin is in