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