iOS的桌面背景运动效果 发表于 2017-11-27 | 12345678910111213_backgroundImage = [[UIImageView alloc] initWithFrame:CGRectMake(-50, -50, Screen_width+100, Screen_Height+100)]; _backgroundImage.image = [UIImage imageNamed:@"bg_1"]; [self.view addSubview:_backgroundImage]; UIInterpolatingMotionEffect * backEffX = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];// type表示沿水平方向运行效果 backEffX.maximumRelativeValue = @(-50); backEffX.minimumRelativeValue = @(50); [self.backgroundImage addMotionEffect:backEffX]; UIInterpolatingMotionEffect * backEffY = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis]; backEffY.maximumRelativeValue = @(-50); backEffY.minimumRelativeValue = @(50); [self.backgroundImage addMotionEffect:backEffY];