android uber启动动画,点击扩散效果(仿uber撤销行程的动画)(ios)

- (IBAction)show:(UIButton

*)sender {

sender.selected

= !sender.isSelected; if (sender.isSelected) {

[CATransaction

begin];

[_shapeCircle

removeAnimationForKey:@"scaleDown"]; CABasicAnimation *scaleAnimation = [self

animateKeyPath:@"transform.scale" fromValue:[NSValue

valueWithCATransform3D:CATransform3DMakeScale(0.0001,

0.0001,

0.0001)] toValue:[NSValue

valueWithCATransform3D:CATransform3DMakeScale(1.0,

1.0,

1.0)] timing:kCAMediaTimingFunctionEaseIn];

[_shapeCircle

addAnimation:scaleAnimation

forKey:@"scaleUp"];

[CATransaction

commit];

} else {

[CATransaction

begin];

[_shapeCircle

removeAnimationForKey:@"scaleUp"]; CABasicAnimation *scaleAnimation = [self

animateKeyPath:@"transform.scale" fromValue:[NSValue

valueWithCATransform3D:CATransform3DMakeScale(1.0,

1.0,

1.0)] toValue:[NSValue

valueWithCATransform3D:CATransform3DMakeScale(0.0001,

0.0001,

0.0001)] timing:kCAMediaTimingFunctionEaseOut];

[_shapeCircle

addAnimation:scaleAnimation

forKey:@"scaleDown"];

[CATransaction

commit];

}

}

- (void)addShapeCircle { _shapeCircle = [CAShapeLayer

layer]; _shapeCircle.fillColor

= [UIColor

colorWithRed:0.078

green:0.196

blue:0.314

alpha:1.000].CGColor; _shapeCircle.transform

= CATransform3DMakeScale(0.0001,

0.0001,

0.0001);

[self.view.layer

insertSublayer:_shapeCircle

atIndex:0]; CGFloat x = CGRectGetWidth(self.view.frame); CGFloat y = CGRectGetHeight(self.view.frame); CGFloat radius = sqrt(x * x + y * y); _shapeCircle.frame

= CGRectMake(x/2

- radius,

y - 65 - radius,

radius * 2,

radius * 2); _shapeCircle.anchorPoint

= CGPointMake(0.5,

0.5); _shapeCircle.path

= [UIBezierPath

bezierPathWithOvalInRect:CGRectMake(0, 0,

radius *

2,

radius *

2)].CGPath;

}

- (CABasicAnimation

*)animateKeyPath:(NSString

*)keyPath fromValue:(id)from toValue:(id)to

timing:(NSString

*)timing { CABasicAnimation *animation = [CABasicAnimation

animationWithKeyPath:keyPath];

animation.fromValue

= from;

animation.toValue

= to;

animation.repeatCount

= 1;

animation.timingFunction

= [CAMediaTimingFunction

functionWithName:timing];

animation.removedOnCompletion

= NO;

animation.fillMode

= kCAFillModeForwards;

animation.duration

= 0.6; return animation;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值