void initButtons() { var moveBtn = UIButton.FromType(UIButtonType.RoundedRect); moveBtn.Frame = new RectangleF(View.Bounds.Width - 240, 60, 200, 40); moveBtn.SetTitle("Move X", UIControlState.Normal); moveBtn.TouchUpInside += (object sender, EventArgs e) => { if (logoView.Layer.PresentationLayer.Position.X < 400) { Rouse.To(logoView, 1, new RouseLib.KeyPaths { PositionX = 400, PositionY = 200 }, Easing.EaseInExpo); Rouse.To(logo, 1, new RouseLib.KeyPaths { PositionX = 400, PositionY = 400 }, Easing.EaseInExpo); } else { Rouse.To(logoView, 1, new RouseLib.KeyPaths { PositionX = 70, PositionY = 110 }, Easing.EaseOutExpo); Rouse.To(logo, 1, new RouseLib.KeyPaths { PositionX = 70, PositionY = 290 }, Easing.EaseOutExpo); } }; View.AddSubview(moveBtn); }
void initButtons() { var btn = new UIButton(UIButtonType.RoundedRect); btn.Frame = new RectangleF(View.Bounds.Width - 340, 60, 200, 40); btn.SetTitle("Toggle Opacity", UIControlState.Normal); btn.TouchUpInside += (object sender, EventArgs e) => { if (logo.PresentationLayer.Opacity > 0) { Rouse.To(logo, 1, new KeyPaths { Opacity = 0 }, Easing.EaseInExpo); Rouse.To(logoView, 1, new KeyPaths { Opacity = 0 }, Easing.EaseInExpo); // TODO pass multiple targets to animation } else { Rouse.To(logo, 1, new KeyPaths { Opacity = 1 }, Easing.EaseOutExpo); Rouse.To(logoView, 1, new KeyPaths { Opacity = 1 }, Easing.EaseInExpo); } }; View.AddSubview(btn); }
void initButtons() { var moveBtn = new UIButton(UIButtonType.RoundedRect); moveBtn.Frame = new RectangleF(View.Bounds.Width * 0.5f - 100, 60, 200, 40); moveBtn.SetTitle("Scale", UIControlState.Normal); moveBtn.TouchUpInside += (object sender, EventArgs e) => { if (logoView.Layer.PresentationLayer.Frame.Width < 200) { Rouse.To(logoView, 1, new KeyPaths { Scale = 2 }, Easing.EaseInExpo); Rouse.To(logo, 1, new KeyPaths { Scale = 2 }, Easing.EaseInExpo); } else { Rouse.To(logoView, 1, new KeyPaths { Scale = 1 }, Easing.EaseOutExpo); Rouse.To(logo, 1, new KeyPaths { Scale = 1 }, Easing.EaseOutExpo); } }; View.AddSubview(moveBtn); }
public void RouseCanTakeTargetDurationAndProperties() { var layer = new CALayer { Frame = new RectangleF(20, 20, 100, 100) }; Rouse.To(layer, 1, new KeyPaths { PositionX = 120 }); Assert.AreEqual(1, layer.AnimationKeys.Length); }
void initButtons() { var moveBtn = UIButton.FromType(UIButtonType.RoundedRect); moveBtn.Frame = new RectangleF(View.Bounds.Width - 240, 60, 200, 40); moveBtn.SetTitle("Move X", UIControlState.Normal); moveBtn.TouchUpInside += (object sender, EventArgs e) => { if (logoView.Layer.PresentationLayer.Position.X < 400) { Rouse.To(logoView, 1, new RouseLib.KeyPaths { PositionX = 400 }, Easing.EaseInExpo); // Rouse.To (logoLayer, 1, new RouseLib.KeyPaths{ PositionX = 400}, Easing.EaseInExpo); var localTime = CAAnimation.CurrentMediaTime(); var ka = new CAKeyFrameAnimation(); ka.KeyPath = "position.x"; ka.BeginTime = 0; ka.Duration = 1; ka.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.Linear); ka.Values = KeyFrameUtils.CreateKeyValues(logoLayer.Position.X, 400f, RouseLib.Easing.EaseInExpo); // var ka2 = new CAKeyFrameAnimation (); // ka2.KeyPath = "opacity"; // ka2.BeginTime = 0; // ka2.Duration = 1; // ka2.TimingFunction = CAMediaTimingFunction.FromName (CAMediaTimingFunction.Linear); // ka2.Values = KeyFrameUtils.CreateKeyValues (1, 0.2f, RouseLib.Easing.EaseInExpo); // var group = CAAnimationGroup.CreateAnimation(); group.BeginTime = localTime; group.Duration = 1; group.FillMode = CAFillMode.Forwards; group.RemovedOnCompletion = false; group.Animations = new CAAnimation[] { ka }; logoLayer.AddAnimation(group, null); } else { Rouse.To(logoView, 1, new RouseLib.KeyPaths { PositionX = 70 }, Easing.EaseOutExpo); // Rouse.To (logoLayer, 1, new RouseLib.KeyPaths{ PositionX = 70}, Easing.EaseOutExpo); var localTime = CAAnimation.CurrentMediaTime(); var ka = new CAKeyFrameAnimation(); ka.KeyPath = "position.x"; ka.BeginTime = 0; ka.Duration = 1; ka.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.Linear); ka.Values = KeyFrameUtils.CreateKeyValues(logoLayer.PresentationLayer.Position.X, 70f, RouseLib.Easing.EaseOutExpo); // var ka2 = new CAKeyFrameAnimation (); // ka2.KeyPath = "opacity"; // ka2.BeginTime = 0; // ka2.Duration = 1; // ka2.TimingFunction = CAMediaTimingFunction.FromName (CAMediaTimingFunction.Linear); // ka2.Values = KeyFrameUtils.CreateKeyValues (1, 0.2f, RouseLib.Easing.EaseInExpo); // var group = CAAnimationGroup.CreateAnimation(); group.BeginTime = localTime; group.Duration = 1; group.FillMode = CAFillMode.Forwards; group.RemovedOnCompletion = false; group.Animations = new CAAnimation[] { ka }; logoLayer.AddAnimation(group, null); } }; View.AddSubview(moveBtn); }