Created
June 4, 2014 10:06
-
-
Save softlion/9ec299924164157ee9a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected static void AddParallaxEffect(UIView back) | |
{ | |
//var frame = back.Frame; | |
//back.Superview.RemoveConstraints(back.Superview.Constraints.Where(c => c.FirstItem == back).ToArray()); | |
//back.Frame = frame; | |
var keypathx = "constraints[0].constant"; | |
var keypathy = "constraints[1].constant"; | |
var xMotionEffect = new UIInterpolatingMotionEffect(keypathx, UIInterpolatingMotionEffectType.TiltAlongHorizontalAxis) | |
{ | |
MinimumRelativeValue = new NSNumber(-10), | |
MaximumRelativeValue = new NSNumber(10) | |
}; | |
var yMotionEffect = new UIInterpolatingMotionEffect(keypathy, UIInterpolatingMotionEffectType.TiltAlongVerticalAxis) | |
{ | |
MinimumRelativeValue = new NSNumber(-10), | |
MaximumRelativeValue = new NSNumber(10) | |
}; | |
back.Superview.AddMotionEffect(new UIMotionEffectGroup {MotionEffects = new[] {xMotionEffect, yMotionEffect}}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment