@@ -141,19 +141,34 @@ - (void)animateToImage:(NSString *)imageName{
141
141
imageV.frame = vFrame;
142
142
[superV addSubview: imageV];
143
143
144
- // animate and remove subview
145
- [NSObject pop_animate: ^{
146
- CGPoint centerP = imageV.center ;
147
- centerP.x += CGRectGetWidth (self.frame ) /2 ;
148
- centerP.y -= CGRectGetHeight (self.frame ) *2 ;
149
- imageV.pop_springSpeed = 1.0 ;
150
- imageV.pop_spring .center = centerP;
151
- imageV.layer .pop_rotation = M_PI_4/2 ;
152
- imageV.pop_spring .pop_scaleXY = CGPointMake (2.0 , 2.0 );
153
- imageV.pop_spring .alpha = 0.0 ;
154
- } completion: ^(BOOL finished) {
155
- [imageV removeFromSuperview ];
144
+ // animate
145
+ CGAffineTransform fromTransform = imageV.transform ;
146
+ CGPoint fromCenter = imageV.center ;
147
+ CGFloat dx = CGRectGetWidth (self.frame ) /2 ;
148
+ CGFloat dy = CGRectGetHeight (self.frame ) *3 ;
149
+ CGFloat dScale = 3.0 ;
150
+ CGFloat dRotation = M_PI_4;
151
+
152
+ NSTimeInterval moveDurarion = 1.0 ;
153
+ POPCustomAnimation *moveA = [POPCustomAnimation animationWithBlock: ^BOOL (id target, POPCustomAnimation *animation) {
154
+ float time_percent = (animation.currentTime - animation.beginTime )/moveDurarion;
155
+ UIView *view = (UIView *)target;
156
+ CGPoint toCenter = CGPointMake (fromCenter.x + time_percent * dx, fromCenter.y - (dy * time_percent * (2 - time_percent)));// 抛物线移动
157
+ view.center = toCenter;
158
+
159
+ CGAffineTransform toTransform = fromTransform;
160
+ toTransform = CGAffineTransformTranslate (toTransform, 50 , -50 );
161
+
162
+ CGFloat toScale = 1 + time_percent *(dScale - 1 );// 线性放大
163
+ toTransform = CGAffineTransformMakeScale (toScale, toScale);
164
+ CGFloat toRotation = dRotation * (1 - cosf (time_percent * M_PI_2));// cos曲线旋转(先慢后快)
165
+ toTransform = CGAffineTransformRotate (toTransform, toRotation);
166
+ view.transform = toTransform;
167
+
168
+ view.alpha = 1 - time_percent;
169
+ return time_percent < 1.0 ;
156
170
}];
171
+ [imageV pop_addAnimation: moveA forKey: @" animateToImage" ];
157
172
}
158
173
}
159
174
@end
0 commit comments