Parallax effect
Parallax effect

In iOS 7, Apple introduced a Parallax effect to the app screen. There is an API available for you to add this effect to your apps. This code lets you add a parallax effect to your apps in iOS 7. I haven’t tested this myself, but it looks like it should work.

Let me know how it goes!

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.background addMotionEffect:interpolationHorizontal];
[self.background addMotionEffect:interpolationVertical];

8 thoughts on “iOS 7 – Add Parallax effect to your apps

  1. From the dev forum: “You might want to add your two motion effects to a UIMotionEffectGroup to ensure that your effects are evaluated simultaneously.”

  2. As well as remove motion effect at the end is good performance practice!
    [self.background removeMotionEffect:interpolationHorizontal];
    [self.background removeMotionEffect:interpolationVertical];

Leave a Reply

Your email address will not be published. Required fields are marked *