本文整理汇总了C#中NSAction.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# NSAction.Invoke方法的具体用法?C# NSAction.Invoke怎么用?C# NSAction.Invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NSAction
的用法示例。
在下文中一共展示了NSAction.Invoke方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransitionOutCompletion
public void TransitionOutCompletion(NSAction action)
{
switch (this.TransitionStyle)
{
case SIAlertViewTransitionStyle.SlideFromBottom:
{
RectangleF rect = this._ContainerView.Frame;
var locationY = this.Bounds.Size.Height;
rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height);
UIView.Animate(
duration: 0.3f,
delay: 0f,
options: UIViewAnimationOptions.CurveEaseIn,
animation: () => { this._ContainerView.Frame = rect; },
completion: () => { if (action != null) action.Invoke(); });
}
break;
case SIAlertViewTransitionStyle.SlideFromTop:
{
RectangleF rect = this._ContainerView.Frame;
var locationY = -rect.Size.Height;
rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height);
UIView.Animate(
duration: 0.3f,
delay: 0f,
options: UIViewAnimationOptions.CurveEaseIn,
animation: () => { this._ContainerView.Frame = rect; },
completion: () => { if (action != null) action.Invoke(); });
}
break;
case SIAlertViewTransitionStyle.Fade:
{
UIView.Animate(
duration: 0.25f,
delay: 0f,
options: UIViewAnimationOptions.CurveEaseIn,
animation: () => { this._ContainerView.Alpha = 0f; },
completion: () => { if (action != null) action.Invoke(); });
}
break;
//case SIAlertViewTransitionStyle,Bounce:
//{
// CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
// animation.values = @[@(1), @(1.2), @(0.01)];
// animation.keyTimes = @[@(0), @(0.4), @(1)];
// animation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
// animation.duration = 0.35;
// animation.delegate = self;
// [animation setValue:completion forKey:@"handler"];
// [self.containerView.layer addAnimation:animation forKey:@"bounce"];
// self.containerView.transform = CGAffineTransformMakeScale(0.01, 0.01);
//}
// break;
case SIAlertViewTransitionStyle.DropDown:
{
PointF point = this._ContainerView.Center;
PointF newPoint = new PointF(point.X, point.Y + this.Bounds.Size.Height);
UIView.Animate(
duration: 0.3f,
delay: 0f,
options: UIViewAnimationOptions.CurveEaseIn,
animation: () =>
{
this._ContainerView.Center = newPoint;
float angle = GetRandomAngle();
this._ContainerView.Transform = CGAffineTransform.MakeRotation(angle);
},
completion: () => { if (action != null) action.Invoke(); });
}
break;
default:
break;
}
}
示例2: TransitionInCompletion
private void TransitionInCompletion(NSAction action)
{
// convenience Func for float-to-NSNumber conversion
Func<float, NSNumber> f = (x) => { return NSNumber.FromFloat(x); };
Func<string, CAMediaTimingFunction> t = (s) => { return CAMediaTimingFunction.FromName(s); };
switch (this.TransitionStyle)
{
case SIAlertViewTransitionStyle.SlideFromBottom:
{
RectangleF originalRect = this._ContainerView.Frame;
RectangleF rect = originalRect;
float locationY = this.Bounds.Size.Height;
rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height);
this._ContainerView.Frame = rect;
UIView.Animate(
duration: 0.3f,
delay: 0f,
options: UIViewAnimationOptions.TransitionNone,
animation: () => { this._ContainerView.Frame = originalRect; },
completion: () => { if (action != null) action.Invoke(); });
}
break;
case SIAlertViewTransitionStyle.SlideFromTop:
{
RectangleF rect = this._ContainerView.Frame;
RectangleF originalRect = rect;
float locationY = -rect.Size.Height;
rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height);
this._ContainerView.Frame = rect;
UIView.Animate(
duration: 0.3f,
delay: 0f,
options: UIViewAnimationOptions.TransitionNone,
animation: () => { this._ContainerView.Frame = originalRect; },
completion: () => { if (action != null) action.Invoke(); });
}
break;
case SIAlertViewTransitionStyle.Fade:
{
this._ContainerView.Alpha = 0f;
UIView.Animate(
duration: 0.3f,
delay: 0f,
options: UIViewAnimationOptions.TransitionNone,
animation: () => { this._ContainerView.Alpha = 1f; },
completion: () => { if (action != null) action.Invoke(); });
}
break;
// These two remaining transition styles are not yet supported because I have not yet figured how to properly wire up the Delegate property on CAKeyFrameAnimation
//case SIAlertViewTransitionStyle.Bounce:
//{
// CAKeyFrameAnimation animation = CAKeyFrameAnimation.GetFromKeyPath(@"transform.scale");
// animation.Values = new NSNumber[] { f(0.01f), f(1.2f), f(0.9f), f(1f) };
// animation.KeyTimes = new NSNumber[] { f(0f), f(0.4f), f(0.6f), f(1f) };
// animation.TimingFunctions = new CAMediaTimingFunction[] { t(CAMediaTimingFunction.Linear.ToString()), t(CAMediaTimingFunction.Linear.ToString()), t(CAMediaTimingFunction.EaseOut.ToString()) };
// animation.Duration = 0.5f;
// animation.Delegate =
// CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
// animation.values = @[@(0.01), @(1.2), @(0.9), @(1)];
// animation.keyTimes = @[@(0), @(0.4), @(0.6), @(1)];
// animation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
// animation.duration = 0.5;
// animation.delegate = self;
// [animation setValue:completion forKey:@"handler"];
// [self.containerView.layer addAnimation:animation forKey:@"bouce"];
//}
//break;
//case SIAlertViewTransitionStyle.DropDown:
//{
// CGFloat y = self.containerView.center.y;
// CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position.y"];
// animation.values = @[@(y - self.bounds.size.height), @(y + 20), @(y - 10), @(y)];
// animation.keyTimes = @[@(0), @(0.5), @(0.75), @(1)];
// animation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
// animation.duration = 0.4;
// animation.delegate = self;
// [animation setValue:completion forKey:@"handler"];
// [self.containerView.layer addAnimation:animation forKey:@"dropdown"];
//}
//break;
// for now, has the same body as the SlideFromTop case;
case SIAlertViewTransitionStyle.DropDown:
{
RectangleF rect = this._ContainerView.Frame;
RectangleF originalRect = rect;
float locationY = -rect.Size.Height;
rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height);
this._ContainerView.Frame = rect;
UIView.Animate(
duration: 0.3f,
//.........这里部分代码省略.........