cakeyframeanimation

CAKeyframeAnimation Manual Progress

荒凉一梦 提交于 2019-12-03 00:39:13
I have a UIView whose backing layer has a CAKeyframeAnimation with a simple straight line path set as its `path`. Can I have the animation "frozen", so to speak, and manually change its progress? For example: If the path is 100 points in length, setting the progress (offset?) to 0.45 should have the view move 45 points down the path. I remember seeing an article that did something similar (moving a view along a path based on the value from a slider) via CAMediaTiming interfaces, but I haven't been able to find it, even after a few hours of searching. If I'm approaching this in a completely

What kind of value is keyTime in an CAKeyFrameAnimation?

南笙酒味 提交于 2019-12-02 19:42:54
For example I have this CAKeyFrameAnimation: CALayer* theLayer = myView.layer; CAKeyframeAnimation* animation; animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"]; animation.duration = 1.6; //animation.cumulative = YES; animation.repeatCount = 1; animation.removedOnCompletion = NO; animation.fillMode = kCAFillModeForwards; animation.values = [NSArray arrayWithObjects: [NSNumber numberWithFloat:0.0 * M_PI], [NSNumber numberWithFloat:(15.0/180.0) * M_PI], [NSNumber numberWithFloat:(30.0/180.0) * M_PI], // animation stops here... [NSNumber numberWithFloat:(45.0/180.0) *

Can I animate the UIScrollView contentOffset property via its layer?

自闭症网瘾萝莉.ら 提交于 2019-12-02 17:09:54
I want to zoom and scroll a UIScrollView with a CGPathRef. Because of that I assume I have to animate the UIScrollView's layer property? But which property would I animate that would make it equivalent to doing a UIView animation and setting its contentOffset property and zoomScale ? These are not properties of a CALayer. Any ideas as to how I would approach this? Again, just want to move the scrollview to a certain contentOffset and zoomScale, but not necessarily linearly from point A to point B, zoom A to zoom B, respectively. I was thinking a CAKeyFrameAnimation with a CGPathRef, but I don

iOS CAKeyframeAnimation rotationMode on UIImageView

南笙酒味 提交于 2019-11-30 13:16:59
问题 I am experimenting with Key Frame animation of the position of a UIImageView object moving along a bezier path. This pic shows the initial state before animation. The blue line is the path - initially moving straight up, the light green box is the initial bounding box or the image, and the dark green "ghost" is the image that I am moving: When I kick off the animation with rotationMode set to nil , the image keeps the same orientation all the way through the path as expected. But when I kick

How to Animate CoreGraphics Drawing of Shape Using CAKeyframeAnimation

梦想的初衷 提交于 2019-11-30 07:35:20
I am trying to animate the drawing of a UIBeizerPath (in my example a triangle) in a UIView subclass. However, the entire subview is animating instead of the shape. Is there something I am missing with the animation? - (void)drawRect:(CGRect)rect { CAShapeLayer *drawLayer = [CAShapeLayer layer]; drawLayer.frame = CGRectMake(0, 0, 100, 100); drawLayer.strokeColor = [UIColor greenColor].CGColor; drawLayer.lineWidth = 4.0; [self.layer addSublayer:drawLayer]; UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:CGPointMake(0,0)]; [path addLineToPoint:CGPointMake(50,100)]; [path

iOS CAKeyframeAnimation rotationMode on UIImageView

ⅰ亾dé卋堺 提交于 2019-11-30 07:01:41
I am experimenting with Key Frame animation of the position of a UIImageView object moving along a bezier path. This pic shows the initial state before animation. The blue line is the path - initially moving straight up, the light green box is the initial bounding box or the image, and the dark green "ghost" is the image that I am moving: When I kick off the animation with rotationMode set to nil , the image keeps the same orientation all the way through the path as expected. But when I kick off the animation with rotationMode set to kCAAnimationRotateAuto , the image immediately rotates 90

How Do You CAKeyframeAnimation Scale?

二次信任 提交于 2019-11-30 02:15:12
I want to create an animation with several key frames. I want my Layer (a button in this case) to scale up to 1.5 then down to 0.5 then up to 1.2 then down to 0.8 then 1.0. I also want to EaseIn and EaseOut of each keyframe. As you can imagine, this will create a Springy/Bounce effect on the spot. In other parts of my app I have been using CAKeyframeAnimation like this (see below code). This creates a similar springy animation but for x and y position. Can I adapt the below code to affect scale instead of position? Thank you in advance! - (CAAnimation*)monInAnimation { CGMutablePathRef path =

Why CAAnimation Rotation is returning to previous state

北城以北 提交于 2019-11-29 18:11:43
I am using CAKeyFrameAnimation to do rotation of an arrow image. Problem is that the imageview is returning back to the previos state after animation. Code: CAKeyframeAnimation *rotation = [CAKeyframeAnimation animation]; rotation.duration = 0.55; rotation.cumulative = TRUE; rotation.removedOnCompletion = NO; if (isFlipRight) { rotation.values = [NSArray arrayWithObjects: [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0.0, 0.0f, 1.0f, 0.0f)], [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0.0f, 1.0f, 0.0f)],nil]; } else { rotation.values = [NSArray arrayWithObjects:

Update view's frame while it's being animated

别来无恙 提交于 2019-11-29 15:40:37
I'm doing an animation like this: CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; animation.duration = 100.0; animation.path = self.animationPath.CGPath; [view.layer addAnimation:animation forKey:@"animation"]; Works fine, however, this now fails when trying to detect touches on the object that is moving around the screen: - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { for (UIView* subview in self.subviews ) { if ( [subview hitTest:[self convertPoint:point toView:subview] withEvent:event] != nil ) { [self handleTap]; return YES; } }

iPhone animation based on input values (touches) not time

独自空忆成欢 提交于 2019-11-29 01:24:46
问题 For an animation effect perfectly suited to an animation group approach as shown in Brad Larson's answer here, I need the animation to proceed according to inputs. Specifically touch and position of detected touches. It is easy to handle touchesMoved: and to set the position of the elements for every touch but it just isn't smooth like the core animation approach. Imagine a marble in a grooved track. I want to push the marble along to any position at any speed in one direction or the other.