cabasicanimation

iOS: a Complete 360 Degree-Rotation Using Block, Not CABasicAnimation

倖福魔咒の 提交于 2019-11-30 06:47:07
问题 It should be something really simple, but I have not been successful in getting this to work using blocks. There are questions and answers to this, but all of them I found are solved by the use of CABasicAnimation and not by UIView Block-Based Animation, which is what I am after. The following code doesn't work (Block-Based), no animation: CGAffineTransform spin = CGAffineTransformRotate(spiningView.transform, DEGREES_RADIANS(360)); CATransform3D identity = CATransform3DIdentity;

CABasicAnimation with CALayer path doesn't animate

狂风中的少年 提交于 2019-11-29 05:34:30
I'm trying to animation the transition of a CALayer from normal corners to rounded corners. I only want to round the top corners, so I am using a UIBezierPath. Here's the code: UIRectCorner corners = UIRectCornerTopLeft | UIRectCornerTopRight; UIBezierPath* newPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(8.0f, 8.0f)]; UIBezierPath* oldPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(0.0f, 0.0f)]; CAShapeLayer* layer = [CAShapeLayer layer]; layer.frame = self.bounds; layer

iOS 8 animation bug

家住魔仙堡 提交于 2019-11-29 00:10:18
问题 I have a simple method for animate view. -(void)animateSelf { CABasicAnimation * animation; animation = [CABasicAnimation animationWithKeyPath:@"position.y"]; // settings ... [self.view.layer addAnimation:animation forKey:@"position.y"]; animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; // settings ... [self.view.layer addAnimation:animation forKey:@"transform.rotation.z"]; [UIView animateWithDuration: 1.0 animations:^{ CGRect rect = self.view.frame; rect.origin.y +

iOS: a Complete 360 Degree-Rotation Using Block, Not CABasicAnimation

こ雲淡風輕ζ 提交于 2019-11-28 21:42:01
It should be something really simple, but I have not been successful in getting this to work using blocks. There are questions and answers to this, but all of them I found are solved by the use of CABasicAnimation and not by UIView Block-Based Animation, which is what I am after. The following code doesn't work (Block-Based), no animation: CGAffineTransform spin = CGAffineTransformRotate(spiningView.transform, DEGREES_RADIANS(360)); CATransform3D identity = CATransform3DIdentity; CATransform3D spin2 = CATransform3DRotate(identity, DEGREES_RADIANS(360), 0.0f, 0.0f, 1.0f); [UIView

Draw circle with UIBezierPath

梦想与她 提交于 2019-11-28 21:32:53
I'm trying to draw a circle using UIBezierPath addArcWithCenter method : UIBezierPath *bezierPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0., 0., 100., 100.)]; [bezierPath addArcWithCenter:center radius:0. startAngle:0 endAngle:2 * M_PI clockwise:YES]; CAShapeLayer *progressLayer = [[CAShapeLayer alloc] init]; [progressLayer setPath:bezierPath.CGPath]; [progressLayer setStrokeColor:[UIColor colorWithWhite:1. alpha:.2].CGColor]; [progressLayer setFillColor:[UIColor clearColor].CGColor]; [progressLayer setLineWidth:.3 * self.bounds.size.width]; [progressLayer setStrokeStart:

How do you animate the sublayers of the layer of a UIView during a UIView animation?

大憨熊 提交于 2019-11-28 20:46:12
In a UIView animation for a view, you can animate its subviews being laid out by including UIViewAnimationOptionLayoutSubviews in the options parameter of [UIView animateWithDuration:delay:options:animations:completion:] . However, I cannot find a way to animate it laying out its sublayers when they are not some view's backing layer; they would just jump into place to match the new bounds of the view. Since I'm working with layers and not views, it seems like I have to use Core Animation instead of UIView animation, but I don't know how (and when) to do this such that the layer animation would

Animating CAShapeLayer size change

瘦欲@ 提交于 2019-11-28 18:24:35
I am drawing a circle, with an initial radius of 200 self.circle = [CAShapeLayer layer]; self.circle.fillColor = nil; self.circle.strokeColor = [UIColor blackColor].CGColor; self.circle.lineWidth = 7; self.circle.bounds = CGRectMake(0, 0, 2 * radius, 2 * radius); self.circle.path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.radius, self.radius) Can anyone please tell me how to animate a change to a radius of 100? This is how I ended up doing it: UIBezierPath *newPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(newRadius, newRadius) radius:newRadius startAngle:(-M_PI/2)

After rotating a CALayer using CABasicAnimation the layer jumps back to it's unrotated position

泪湿孤枕 提交于 2019-11-28 16:59:31
I am trying to create a falling coin. The coin image is a CALayer with 2 CABasicAnimations on it - a falling down and a rotation one. When the falling down animation gets to its end, it stays there. The rotation animation though, which is supposed to be random and end up in a different angle every time, just pops back to the original CALAyer image. I want it to stay in the angle it finished the animation on. Is it possible? How do I do it? Code: //Moving down animation: CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform.translation.y"]; anim.duration = 1; anim

CAShapeLayer Animating Path Glitches / Flickers (From Ellipse to Rect and back)

被刻印的时光 ゝ 提交于 2019-11-28 09:22:46
I am running into an issue when I create an explicit animation to change the value of a CAShapeLayer's path from an ellipse to a rect. In my canvas controller I setup a basic CAShapeLayer and add it to the root view's layer: CAShapeLayer *aLayer; aLayer = [CAShapeLayer layer]; aLayer.frame = CGRectMake(100, 100, 100, 100); aLayer.path = CGPathCreateWithEllipseInRect(aLayer.frame, nil); aLayer.lineWidth = 10.0f; aLayer.strokeColor = [UIColor blackColor].CGColor; aLayer.fillColor = [UIColor clearColor].CGColor; [self.view.layer addSublayer:aLayer]; Then, when I animate the path I get a strange

iOS animate/morph shape from circle to square

巧了我就是萌 提交于 2019-11-28 07:00:15
I try to change a circle into a square and vice versa and I am almost there. However it doesn't animates as expected. I would like all corners of a square to be animated/morphed at the same time but what I get is the following: I use CAShapeLayer and CABasicAnimation in order to animate shape property. Here is how I create the circle path: - (UIBezierPath *)circlePathWithCenter:(CGPoint)center radius:(CGFloat)radius { UIBezierPath *circlePath = [UIBezierPath bezierPath]; [circlePath addArcWithCenter:center radius:radius startAngle:0 endAngle:M_PI/2 clockwise:YES]; [circlePath addArcWithCenter