Skip to content

Instantly share code, notes, and snippets.

@mbaranowski
Created January 15, 2014 21:24
Show Gist options
  • Save mbaranowski/8444983 to your computer and use it in GitHub Desktop.
Save mbaranowski/8444983 to your computer and use it in GitHub Desktop.
UIMotionEffectGroup* effectGroup = [[UIMotionEffectGroup alloc] init];
UIInterpolatingMotionEffect* horizontalParallax =
[[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center"
type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
UIInterpolatingMotionEffect* verticalParallax =
[[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center"
type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
CGFloat offset = 50;
horizontalParallax.minimumRelativeValue = [NSValue valueWithCGPoint:CGPointMake(-offset, 0)];
horizontalParallax.maximumRelativeValue = [NSValue valueWithCGPoint:CGPointMake( offset, 0)];
verticalParallax.minimumRelativeValue = [NSValue valueWithCGPoint:CGPointMake( 0, -offset)];
verticalParallax.maximumRelativeValue = [NSValue valueWithCGPoint:CGPointMake( 0, offset)];
effectGroup.motionEffects = @[horizontalParallax, verticalParallax];
[self.blurredBackgroundView addMotionEffect:effectGroup];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment