iOS实现一个动画
模仿一个汽车大全首页的动画按钮,动画分解如下:1.主按钮旋转-45度。
2.向目标点弹出子按钮。
3.回弹效果。
代码如下,求大神指点。
iOS 动画 --------------------编程问答-------------------- 汽车大全是什么 app,没听说过,模仿他作甚 --------------------编程问答-------------------- --------------------编程问答-------------------- 我建议你去IOS开发相关,了解一下。 --------------------编程问答-------------------- 求demo下载~~ --------------------编程问答-------------------- 动画不错,写Demo玩玩而已
//1.旋转 -45度
CABasicAnimation *revolve = [CABasicAnimation animationWithKeyPath:@"transform"];
revolve.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
revolve.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(-M_PI/360*60, 0, 0, 1)];
revolve.cumulative = YES;
revolve.duration =0.6;
revolve.removedOnCompletion = YES;
[btn.layer addAnimation:revolve forKey:nil];
//保持旋转后的状态
btn.layer.transform = CATransform3DMakeRotation(-M_PI/360*60, 0, 0, 1);
//btn.tag = 1;
//2.弹出子功能按钮
UIBezierPath *movepath = [UIBezierPath bezierPath];
SubBtn *subbtn = [_btnArr objectAtIndex:0];
subbtn.hidden = NO;
NSLog(@"%@",subbtn);
[movepath moveToPoint:subbtn.center];
[movepath addQuadCurveToPoint:subbtn.goalpoint controlPoint:subbtn.goalpoint];
CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
moveAnim.path = movepath.CGPath;
moveAnim.removedOnCompletion = YES;
moveAnim.duration = 3;
//[subbtn.layer addAnimation:moveAnim forKey:nil];
//2.1回弹效果 ->打出去 弹回来
// UIBezierPath *returnPath = [UIBezierPath bezierPath];
// [returnPath moveToPoint:subbtn.goalpoint];
// [returnPath addQuadCurveToPoint:subbtn.tempoint controlPoint:subbtn.tempoint];
//
//
// CAKeyframeAnimation *returnAnim = [CAKeyframeAnimation animationWithKeyPath:@"psition"];
// returnAnim.path = returnPath.CGPath;
// returnAnim.removedOnCompletion = YES;
// returnAnim.duration = 0.8;
// [subbtn.layer addAnimation:returnAnim forKey:nil];
//
////
UIBezierPath *backPath = [UIBezierPath bezierPath];
[backPath moveToPoint:subbtn.goalpoint];
[backPath addQuadCurveToPoint:subbtn.goalpoint controlPoint:subbtn.tempoint];
CAKeyframeAnimation *backAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
backAnim.path = backPath.CGPath;
backAnim.removedOnCompletion = YES;
backAnim.duration = 0.8;
CAAnimationGroup *gp = [CAAnimationGroup animation];
gp.animations = [NSArray arrayWithObjects:moveAnim,backAnim, nil];
[subbtn.layer addAnimation:gp forKey:nil];
subbtn.center = subbtn.goalpoint;
补充:移动开发 , iPhone