partial void ChangeViewPressed(Foundation.NSObject sender)
        {
            var button = sender as UIButton;

            button.Selected = !button.Selected;


            var animation = POPSpringAnimation.AnimationWithPropertyNamed(POPAnimation.LayoutConstraintConstant);

            animation.ToValue = new NSNumber(button.Selected ? (ContainerViewWidthConstraint.Constant + 16) * -1 : 0);
            ContainerViewConstraint.AddAnimation(animation, "constraint");
        }
Ejemplo n.º 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.
            button = new UIButton()
            {
                BackgroundColor = UIColor.FromHSBA(0.531f, 1, 1, 1),
                Frame           = new RectangleF(0, 0, 140, 140),
            };
            button.SetTitleColor(UIColor.White, UIControlState.Normal);
            button.SetTitle("Tap to start", UIControlState.Normal);
            button.Layer.CornerRadius = 70;

            button.TouchUpInside += delegate {
                var anim = button.PopAnimationForKey("bounce.me");
                if (anim != null)
                {
                    button.PopRemoveAnimationForKey("bounce.me");
                    button.SetTitle("Tap to start", UIControlState.Normal);
                }
                else
                {
                    float              size      = 1;
                    NSValue            fromValue = NSValue.FromSizeF(new SizeF(size, size));
                    NSValue            toValue   = NSValue.FromSizeF(new SizeF(1.4f, 1.4f));
                    POPSpringAnimation bounce    = POPSpringAnimation.AnimationWithPropertyNamed(POPMutableAnimatableProperty.POPViewScaleXY);
                    bounce.SpringBounciness = 14;
                    bounce.FromValue        = fromValue;
                    bounce.ToValue          = toValue;

                    // Note: CompletionBlock is much more reliable than Finished
                    bounce.CompletionBlock = delegate(POPAnimation animation, bool finished) {
                        if (finished)
                        {
                            // Auto-reverse
                            var prevFrom = (animation as POPSpringAnimation).FromValue;
                            (animation as POPSpringAnimation).FromValue = (animation as POPSpringAnimation).ToValue;
                            (animation as POPSpringAnimation).ToValue   = prevFrom;
                            button.PopAddAnimation(animation, "bounce.me");
                        }
                    };

                    button.PopAddAnimation(bounce, "bounce.me");
                    button.SetTitle("Tap to stop", UIControlState.Normal);
                }
            };

            button.Center = View.Center;
            View.Add(button);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            PopButton.TouchUpInside += (object sender, EventArgs e) => {
                var springAnimation = POPSpringAnimation.AnimationWithPropertyNamed(POPAnimation.ViewCenter);
                var newCenter       = PopButton.Center;
                newCenter.Y                      = newCenter.Y + 200;
                springAnimation.ToValue          = NSValue.FromCGPoint(newCenter);
                springAnimation.CompletionAction = (POPAnimation arg1, bool arg2) => {
                    var decayAnimation = POPDecayAnimation.AnimationWithPropertyNamed(POPAnimation.LayerPositionY);
                    decayAnimation.Velocity      = new NSNumber(-800);
                    decayAnimation.AutoReverse   = true;
                    decayAnimation.RepeatForever = true;
                    decayAnimation.ClampMode     = POPAnimationClampFlags.Both;
                    PopButton.AddAnimation(decayAnimation, "Decay");
                };
                PopButton.AddAnimation(springAnimation, "Center");
            };
        }