以下是重构后的内容:

1. 创建一个UIBezierPath对象:`UIBezierPath *path = [UIBezierPath bezierPath];`

2. 将路径移动到起始点:`[path moveToPoint:CGPointMake(-40, 100)];`

3. 在路径上添加一条从起始点到终点的线段:`[path addLineToPoint:CGPointMake(360, 100)];`

4. 在路径上添加一条从终点到起始点的线段:`[path addLineToPoint:CGPointMake(360, 200)];`

5. 在路径上添加一条从终点到起始点的线段:`[path addLineToPoint:CGPointMake(-40, 200)];`

6. 在路径上添加一条从起点到终点的线段:`[path addLineToPoint:CGPointMake(-40, 300)];`

7. 在路径上添加一条从起点到终点的线段:`[path addLineToPoint:CGPointMake(360, 300)];`

8. 如果需要在动画中旋转,可以设置旋转模式为kCAAnimationRotateAuto:`moveAnimation.rotationMode = kCAAnimationRotateAuto;`

9. 为shapeLayer添加动画:`[shapeLayer addAnimation:moveAnimation forKey:@"moveAnimation"];`

```objc

UIBezierPath *path = [UIBezierPath bezierPath];

[path moveToPoint:CGPointMake(-40, 100)];

[path addLineToPoint:CGPointMake(360, 100)];

[path addLineToPoint:CGPointMake(360, 200)];

[path addLineToPoint:CGPointMake(-40, 200)];

[path addLineToPoint:CGPointMake(-40, 300)];

[path addLineToPoint:CGPointMake(360, 300)];

CAKeyframeAnimation *moveAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];

moveAnimation.path = path.CGPath;

moveAnimation.duration = 8.0f;

moveAnimation.rotationMode = kCAAnimationRotateAuto;

moveAnimation.delegate = self; // 如果需要处理动画结束时的回调事件

[shapeLayer addAnimation:moveAnimation forKey:@"moveAnimation"];

```

CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@\"transform"];

CATransform3D scale1 = CATransform3DMakeScale(0.5, 0.5, 1);

CATransform3D scale2 = CATransform3DMakeScale(1.2, 1.2, 1);

CATransform3D scale3 = CATransform3DMakeScale(0.9, 0.9, 1);

CATransform3D scale4 = CATransform3DMakeScale(1.0, 1.0, 1);

NSArray *frameValues = [NSArray arrayWithObjects:

[NSValue valueWithCATransform3D:scale1],

[NSValue valueWithCATransform3D:scale2],

[NSValue valueWithCATransform3D:scale3],

[NSValue valueWithCATransform3D:scale4],

nil];

[animation setValues:frameValues];

NSArray *frameTimes = [NSArray arrayWithObjects:

[NSNumber numberWithFloat:0.0],

[NSNumber numberWithFloat:0.5],

[NSNumber numberWithFloat:0.9],

[NSNumber numberWithFloat:1.0],

nil];

[animation setKeyTimes:frameTimes];

animation.fillMode = kCAFillModeForwards;

animation.duration = .25;

[self addAnimation:animation forKey:@\"DSPopUpAnimation\"];

基于路径的关键帧动画:

1. 创建一个可变的CGMutablePathRef对象。

```objc

CGMutablePathRef path = CGPathCreateMutable();

```

2. 定义起始点,将坐标设置为(50.0, 120.0)。

```objc

CGPathMoveToPoint(path, NULL, 50.0, 120.0);

```

3. 添加曲线到指定的点。

```objc

CGPathAddCurveToPoint(path, NULL, 50.0, 275.0, 150.0, 275.0, 150.0, 120.0);

CGPathAddCurveToPoint(path,NULL,150.0,275.0,250.0,275.0,250.0,120.0);

CGPathAddCurveToPoint(path,NULL,250.0,275.0,350.0,275.0,350.0,120.0);

CGPathAddCurveToPoint(path,NULL,350.0,275.0,450.0,275.0,450.0,120.0);

```

4. 将动画的持续时间设置为3秒。

```objc

[anim setDuration:3.0];

```

5. 设置动画是否自动反转。

```objc

[anim setAutoreverses:YES];

```

6. 释放路径对象的内存。

```objc

CFRelease(path);

```

7. 将动画添加到图层上。

```objc

[self.layer addAnimation:anim forKey:@"position"];

```

```objc

CGPoint pt0 = CGPointMake(50.0, 120.0);

CGPoint pt1 = CGPointMake(50.0, 275.0);

CGPoint pt2 = CGPointMake(150.0, 275.0);

CGPoint pt3 = CGPointMake(150.0, 120.0);

CGPoint pt4 = CGPointMake(150.0, 275.0);

CGPoint pt5 = CGPointMake(250.0, 275.0);

CGPoint pt6 = CGPointMake(250.0, 120.0);

CGPoint pt7 = CGPointMake(250.0, 275.0);

CGPoint pt8 = CGPointMake(350.0, 275.0);

CGPoint pt9 = CGPointMake(350.0, 120.0);

CGPoint pt10 = CGPointMake(350.0, 275.0);

CGPoint pt11 = CGPointMake(450.0, 275.0);

CGPoint pt12 = CGPointMake(450.0, 120.0);

NSArray *values = @[@[@15, @[@{@"position": @[@pt0]}], @{@"position": @[@pt1]}], @{@"position": @[@pt2]}, @{@"position": @[@pt3]}, @{@"position": @[@pt4]}, @{@"position": @[@pt5]}, @{@"position": @[@pt6]}, @{@"position": @[@pt7]}, @{@"position": @[@pt8]}, @{@"position": @[@pt9]}, @{@"position": @[@pt10]}, @{@"position": @[@pt11]}, @{@"position": @[@pt12]}]];

CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"position"];

[anim setValues:values];

[anim setDuration:3.0];

[anim setAutoreverses:YES];

[self.layer addAnimation:anim forKey:@"path"];

```

请提供需要重构的内容,以便我为您提供帮助。

以下是重构后的代码:

```objc

CAKeyframeAnimation *keyAnim = [CAKeyframeAnimation animationWithKeyPath:@"transform"];

CATransform3D rotation1 = CATransform3DMakeRotation(30 * M_PI / 180, 0, 0, -1);

CATransform3D rotation2 = CATransform3DMakeRotation(60 * M_PI / 180, 0, 0, -1);

CATransform3D rotation3 = CATransform3DMakeRotation(90 * M_PI / 180, 0, 0, -1);

CATransform3D rotation4 = CATransform3DMakeRotation(120 * M_PI / 180, 0, 0, -1);

CATransform3D rotation5 = CATransform3DMakeRotation(150 * M_PI / 180, 0, 0, -1);

CATransform3D rotation6 = CATransform3DMakeRotation(180 * M_PI / 180, 0, 0, -1);

[keyAnim setValues:@[@(1), @(rotation1.matrix), @(rotation2.matrix), @(rotation3.matrix), @(rotation4.matrix), @(rotation5.matrix), @(rotation6.matrix), nil]];

[keyAnim setKeyTimes:@[@(0.0f), @(0.2f), @(0.4f), @(0.6f), @(0.8f), @(1.0f), nil]];

[keyAnim setDuration:4];

[keyAnim setFillMode:kCAFillModeForwards];

[keyAnim setRemovedOnCompletion:NO];

[zhiZhenLayer addAnimation:keyAnim forKey:nil];

```

主要重构了以下几点:

1. 将所有的数字和角度值提取到一个数组中。

2. 将所有的旋转矩阵提取到一个数组中。

3. 将设置动画关键帧的代码进行简化。