void AddContentViewControllerMotionEffects() { if (_parallaxEnabled) { if (_ios7) { if (_contentViewContainer.MotionEffects != null) { foreach (UIMotionEffect effect in _contentViewContainer.MotionEffects) { _contentViewContainer.RemoveMotionEffect(effect); } } UIView.Animate(0.2, () => { UIInterpolatingMotionEffect interpolationHorizontal = new UIInterpolatingMotionEffect("center.x", UIInterpolatingMotionEffectType.TiltAlongHorizontalAxis); interpolationHorizontal.MinimumRelativeValue = NSObject.FromObject(_parallaxContentMinimumRelativeValue); interpolationHorizontal.MaximumRelativeValue = NSObject.FromObject(_parallaxContentMaximumRelativeValue); UIInterpolatingMotionEffect interpolationVertical = new UIInterpolatingMotionEffect("center.y", UIInterpolatingMotionEffectType.TiltAlongVerticalAxis); interpolationVertical.MinimumRelativeValue = NSObject.FromObject(_parallaxContentMinimumRelativeValue); interpolationVertical.MaximumRelativeValue = NSObject.FromObject(_parallaxContentMaximumRelativeValue); _contentViewContainer.AddMotionEffect(interpolationHorizontal); _contentViewContainer.AddMotionEffect(interpolationVertical); }); } } }
public static UIView AddMotion(this UIView view, float min, float max) { view.AddMotionEffect(new UIInterpolatingMotionEffect("center.x", UIInterpolatingMotionEffectType.TiltAlongHorizontalAxis) { MinimumRelativeValue = new NSNumber(min), MaximumRelativeValue = new NSNumber(max) }); view.AddMotionEffect(new UIInterpolatingMotionEffect("center.y", UIInterpolatingMotionEffectType.TiltAlongVerticalAxis) { MinimumRelativeValue = new NSNumber(min), MaximumRelativeValue = new NSNumber(max) }); return(view); }
private void AddMenuViewControllerMotionEffects() { if (ParallaxEnabled) { foreach (var me in _menuViewContainer.MotionEffects) { _menuViewContainer.RemoveMotionEffect(me); } var interpolationHorizontal = new UIInterpolatingMotionEffect("center.x", UIInterpolatingMotionEffectType.TiltAlongHorizontalAxis); interpolationHorizontal.MinimumRelativeValue = new NSNumber(ParallaxMenuMinimumRelativeValue); interpolationHorizontal.MaximumRelativeValue = new NSNumber(ParallaxMenuMaximumRelativeValue); var interpolationVertical = new UIInterpolatingMotionEffect("center.y", UIInterpolatingMotionEffectType.TiltAlongVerticalAxis); interpolationVertical.MinimumRelativeValue = new NSNumber(ParallaxMenuMinimumRelativeValue); interpolationVertical.MaximumRelativeValue = new NSNumber(ParallaxMenuMaximumRelativeValue); _menuViewContainer.AddMotionEffect(interpolationHorizontal); _menuViewContainer.AddMotionEffect(interpolationVertical); } }
public static void ApplyMotionEffects(this UIView view, float horizontalRange = 10.0f, float verticalRange = 10.0f) { if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0)) { UIInterpolatingMotionEffect horizontalEffect = new UIInterpolatingMotionEffect("center.x", UIInterpolatingMotionEffectType.TiltAlongHorizontalAxis); horizontalEffect.MinimumRelativeValue = NSNumber.FromFloat(-horizontalRange); horizontalEffect.MaximumRelativeValue = NSNumber.FromFloat(horizontalRange); UIInterpolatingMotionEffect verticalEffect = new UIInterpolatingMotionEffect("center.y", UIInterpolatingMotionEffectType.TiltAlongVerticalAxis); verticalEffect.MinimumRelativeValue = NSNumber.FromFloat(-verticalRange); verticalEffect.MaximumRelativeValue = NSNumber.FromFloat(verticalRange); UIMotionEffectGroup motionEffectGroup = new UIMotionEffectGroup(); motionEffectGroup.MotionEffects = new UIMotionEffect[] { horizontalEffect, verticalEffect }; view.AddMotionEffect(motionEffectGroup); } }
private void ApplyMotionEffect(UIView view, nfloat magnitude) { var xMotion = new UIInterpolatingMotionEffect("center.x", UIInterpolatingMotionEffectType.TiltAlongHorizontalAxis); var yMotion = new UIInterpolatingMotionEffect("center.y", UIInterpolatingMotionEffectType.TiltAlongVerticalAxis); xMotion.MinimumRelativeValue = FromObject(-magnitude); xMotion.MaximumRelativeValue = FromObject(magnitude); yMotion.MinimumRelativeValue = FromObject(-magnitude); yMotion.MaximumRelativeValue = FromObject(magnitude); var motionGroup = new UIMotionEffectGroup { MotionEffects = new UIMotionEffect[] { xMotion, yMotion } }; view.AddMotionEffect(motionGroup); }
public static UIMotionEffect SetParallaxIntensity(this UIView view, float parallaxDepth, float?verticalDepth = null) { if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0)) { float vertical = verticalDepth ?? parallaxDepth; var verticalMotionEffect = new UIInterpolatingMotionEffect("center.y", UIInterpolatingMotionEffectType.TiltAlongVerticalAxis); verticalMotionEffect.MinimumRelativeValue = new NSNumber(-vertical); verticalMotionEffect.MaximumRelativeValue = new NSNumber(vertical); var horizontalMotionEffect = new UIInterpolatingMotionEffect("center.x", UIInterpolatingMotionEffectType.TiltAlongHorizontalAxis); horizontalMotionEffect.MinimumRelativeValue = new NSNumber(-parallaxDepth); horizontalMotionEffect.MaximumRelativeValue = new NSNumber(parallaxDepth); var group = new UIMotionEffectGroup(); group.MotionEffects = new UIMotionEffect[] { horizontalMotionEffect, verticalMotionEffect }; view.AddMotionEffect(group); return(group); } return(null); }
public static void ApplyMotionEffects(this UIView view) { int SystemVersion = Convert.ToInt16(UIDevice.CurrentDevice.SystemVersion.Split('.') [0]); if (SystemVersion >= 7) { UIInterpolatingMotionEffect horizontalEffect = new UIInterpolatingMotionEffect("center.x", UIInterpolatingMotionEffectType.TiltAlongHorizontalAxis); horizontalEffect.MinimumRelativeValue = NSNumber.FromFloat(-10); horizontalEffect.MaximumRelativeValue = NSNumber.FromFloat(10); UIInterpolatingMotionEffect verticalEffect = new UIInterpolatingMotionEffect("center.6", UIInterpolatingMotionEffectType.TiltAlongVerticalAxis); verticalEffect.MinimumRelativeValue = NSNumber.FromFloat(-10); verticalEffect.MaximumRelativeValue = NSNumber.FromFloat(10); UIMotionEffectGroup motionEffectGroup = new UIMotionEffectGroup(); motionEffectGroup.MotionEffects = new UIMotionEffect[] { horizontalEffect, verticalEffect }; view.AddMotionEffect(motionEffectGroup); } }