Skip to main content

Posts

Showing posts from October, 2013

How to add parallax effect to your apps

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; UIMotionEffectGroup *interpolationGroup = [[UIMotionEffectGroup alloc]init]; interpolationGroup.motionEffects = [NSArray arrayWithObjects:interpolationHorizontal, interpolationVertical, nil]; if([aView respondsToSelector:@selector(addMotionEffect:)]){ [aView addMotionEffect:interpolationGroup]; }