当前位置: 首页>>代码示例>>C#>>正文


C# UIButton.PopAddAnimation方法代码示例

本文整理汇总了C#中UIButton.PopAddAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# UIButton.PopAddAnimation方法的具体用法?C# UIButton.PopAddAnimation怎么用?C# UIButton.PopAddAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UIButton的用法示例。


在下文中一共展示了UIButton.PopAddAnimation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ViewDidLoad

        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);
        }
开发者ID:joewest,项目名称:pop-monotouch,代码行数:47,代码来源:MainViewController.cs


注:本文中的UIButton.PopAddAnimation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。