视图弹出后放大又缩小的动画实现、类似于alertView效果
国阳
2023-12-01
- (
void
) shakeToShow:(
UIView
*)aView{
CAKeyframeAnimation
* animation = [
CAKeyframeAnimation
animationWithKeyPath
:
@"transform"
];
animation.
duration
=
0.5
;
NSMutableArray
*values = [
NSMutableArray
array
];
[values
addObject
:[
NSValue
valueWithCATransform3D
:
CATransform3DMakeScale
(
0.1
,
0.1
,
1.0
)]];
[values
addObject
:[
NSValue
valueWithCATransform3D
:
CATransform3DMakeScale
(
1.2
,
1.2
,
1.0
)]];
[values
addObject
:[
NSValue
valueWithCATransform3D
:
CATransform3DMakeScale
(
0.9
,
0.9
,
1.0
)]];
[values
addObject
:[
NSValue
valueWithCATransform3D
:
CATransform3DMakeScale
(
1.0
,
1.0
,
1.0
)]];
animation.
values
= values;
[aView.
layer
addAnimation
:animation
forKey
:
nil
];
}