我刚刚看到Facebook的新纸质应用程序,使图像基于视差效果移动.因此,它将图像缩放到全屏,当您倾斜屏幕时,它会将图像滚动到您倾斜的一侧.我已经能够像苹果那样添加视差效果,但不像facebook那样.有没有人有任何想法如何他们这样做.这是我用于视差的基本代码:
UIInterpolatingMotionEffect *interpolationHorizontal = [[UIInterpolatingMotionEffect alloc]initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
interpolationHorizontal.minimumRelativeValue = @-10.0;
interpolationHorizontal.maximumRelativeValue = @10.0;
UIInterpolatingMotionEffect *interpolationVertical = [[UIInterpolatingMotionEffect alloc]initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
interpolationVertical.minimumRelativeValue = @-10.0;
interpolationVertical.maximumRelativeValue = @10.0;
[self.backgroundView addMotionEffect:interpolationHorizontal];
[self.backgroundView addMotionEffect:interpolationVertical];
Run Code Online (Sandbox Code Playgroud)