core-animation

What's the easiest way to animate a line?

天涯浪子 提交于 2019-12-04 06:50:27
I am creating an app that involves animating lines within a workspace over time. My current approach for this is to use code like this in drawRect : CGContextSetStrokeColor(context, black); CGContextBeginPath(context); CGContextMoveToPoint(context, startPoint.x, startPoint.y); CGContextAddLineToPoint(context, finalPoint.x, finalPoint.y); CGContextStrokePath(context); ...and then just setting a timer to run every 0.05 seconds to update finalPoint and call setNeedsDisplay . I'm finding this approach (when there's 5ish lines moving at once) slows down the app terribly, and even with such a high

CABasicAnimation not changing its position property after animation completes

江枫思渺然 提交于 2019-12-04 06:09:04
i am applying CABasicAnimation for position property of a layer it is animating well but after animation complete its coming back to original position how to avoid that and to make image to stay in animated position only? Andrew Zimmer There are a few different ways to solve this. My favorite is to set the object at the end of the animation, and use fromValue instead of toValue to create the animation. You can also set both fromValue and toValue to create this effect. ie CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; animation.duration = 1.0; animation

Internal implementation of UIView's block-based animation methods

╄→尐↘猪︶ㄣ 提交于 2019-12-04 06:03:46
Ever since their introduction in iOS 4, I have been wondering about the internal implementation of the UIView 's block-based animation methods. In particular I would like to understand what mystical features of Objective C are used there to capture all the relevant layer state changes before and after execution of the animation block. Observing the black-box implementation, I gather that it needs to capture the before-state of all layer properties modified in the animation block, to create all the relevant CAAnimations . I guess it does not do a snapshot of whole view hierarchy, as that would

If statement on NSNotificationCenter in iOS

▼魔方 西西 提交于 2019-12-04 06:01:58
问题 I'm trying start another animation when one ends. I am checking for callbacks like this: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(animationDidStopNotification:) name:ImageAnimatorDidStopNotification object:animatorViewController]; How do I make an if statement that lets me do trigger something when ImageAnimatorDidStopNotification is received? Thanks! 回答1: You didn't post enough code to know what are you trying to do and where is the problem. If you want to

Custom animatable property returns NSNull?

旧街凉风 提交于 2019-12-04 05:52:04
Only one day left on the bounty! Can you have a custom animatable property work with the UIView animateWithDuration block syntax? I've been working on creating my own implicit animation for a custom animatable property on a custom CALayer . I have set the backing layer of a custom UIView and can use a CATransaction to animate the custom property (in the custom example I am changing the color of a circle with a custom property circleColor ). I know that UIView turns off animatable properties by returning NSNull from the actionForLayer:forKey: selector method on UIView . Then when the property

Core Animation, unexpected animated position and hitTest values

泄露秘密 提交于 2019-12-04 05:41:23
问题 When I use : CALayer *hitLayer = [[self.view.window.layer presentationLayer] hitTest:pointOfTouch]; I then explore the layer to discover that all the property that are animating at the moment are set to their final states. The layer I'm testing on is the CALayer of an UIImageView in iOS 4.3. I also have an IBOutlet to that UIImage view. So I did the same test like this: CALayer *l = [self.topLeft.layer presentationLayer]; NSLog(@"presentation layer frame for eloise is : %@", [self

Animation Snaps back when the UIImage is changed

China☆狼群 提交于 2019-12-04 05:32:46
问题 I have an UIImageView that runs across the screen when a button is pressed and held. When the button is pressed is changes the UIImage of the UIImageView and when the button is let go I change it to its original UIImage. When ever the image changes back it snaps back to the location that the image started. This Timer is called when the button is pressed: //This is the image that changes when the button is pressed. imView.image = image2; runTimer = [NSTimer scheduledTimerWithTimeInterval:0.04

How to Anti-Alias Layers in iPhoneOS

自闭症网瘾萝莉.ら 提交于 2019-12-04 04:53:56
We've had Reiner Knizia's Money out for a couple of months now. It's done pretty well, and so we've been updating it as time allows. However, one thing continues to bug me. I've never been able to get my layered cards to anti-alias correctly. Here's a sample: Cards that are laid straight are very clean, but whenever they're angled the black lines around the cards get jagged. I've tried this depending on both lines implicit to the artwork and lines drawn through drawRect:, and they both do the same thing. I've tried the edgeAntiAliasingMask and it doesn't do a thing as far as I can tell. I've

Gradient Animation - Slow down and speed up

此生再无相见时 提交于 2019-12-04 02:18:11
问题 I'm animating a CAGradientLayer , similar to how Apple did with their "Slide to Unlock" animation on the home screen of iPhone. However my animation is a little different in that it slows down and speeds up at certain points. The code I have so far is animates a gradient and works, but how would I get it to slow down/speed up at different points? class AnimatedMaskLabel: UIView { let gradientLayer: CAGradientLayer = { let gradientLayer = CAGradientLayer() // Configure the gradient here

Change CAShapeLayer without Animation

柔情痞子 提交于 2019-12-04 01:12:51
I want to set the strokeEnd property of a CAShapeLayer without the default animation, with no animation at all. I've looked around to try to find how to do this but everything seems to be about how to animate properties. David Rönnqvist In Core Animations terminology, a more general term for an animation is an "action". You can for example see that the CAAnimation conforms to the CAAction protocol. You also see the terminology "action" used when disabling them (disabling the animations). There are many different ways of changing the actions of a layer. Many of them are documented pretty well