// 设置在x轴的偏移范围
UIInterpolatingMotionEffect * fairyEffX = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];// type表示沿水平方向运行效果
fairyEffX.maximumRelativeValue = @(50);
fairyEffX.minimumRelativeValue = @(-50);
// 为view添加运动效果
[imageview addMotionEffect:fairyEffX];
UIInterpolatingMotionEffect * fairyEffY = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
fairyEffY.maximumRelativeValue = @(50);
fairyEffY.minimumRelativeValue = @(-50);
[imageview addMotionEffect:fairyEffY];
// 设置背景的运动效果 ===== BEGIN =====
UIInterpolatingMotionEffect * backEffX = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];// type表示沿水平方向运行效果
backEffX.maximumRelativeValue = @(-100);
backEffX.minimumRelativeValue = @(100);
[self.back addMotionEffect:backEffX];
UIInterpolatingMotionEffect * backEffY = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
backEffY.maximumRelativeValue = @(-100);
backEffY.minimumRelativeValue = @(100);
[backimageview addMotionEffect:backEffY];