简体   繁体   English

在Xamarin中使用transitionWithView设置UIView.Hidden属性时淡出动画

[英]Fade animation when setting UIView.Hidden property with transitionWithView in Xamarin

I am trying to translate this code in my solution to enable a view to gracefully fade when clicked: 我正在尝试在我的解决方案中翻译此代码 ,以使视图在单击时能够优雅消失:

[UIView transitionWithView:button
     duration:0.4
     options:UIViewAnimationOptionTransitionCrossDissolve
     animations:NULL
     completion:NULL];

button.hidden = YES;

But I can't find the equivalent of transitionWithView under UIView in Xamarin, can someone advise? 但是我在Xamarin的UIView下找不到等效的transitionWithView ,有人可以建议吗?

I tried this for a different animation but it does not give the option of dissolving: 我为其他动画尝试了此操作,但它没有提供溶解的选项:

UIView.SetAnimationTransition(UIViewAnimationTransition.CurlDown, button, true);

Setting the hidden property will just hide the UIView. 设置hidden属性将仅隐藏UIView。 You can use the following code to animate out your view, and use the callback to execute logic when the animation is done. 您可以使用以下代码对视图进行动画处理,并在完成动画后使用回调执行逻辑。

UIView.Animate (2, 0, UIViewAnimationOptions.CurveLinear,
    () => {
       button.Alpha = 0.0f;
    },
    () => {
      // animation complete logic 
    }
);

The code above will fade out the button view over 2 second, with a delay of 0 seconds using a linear curve. 上面的代码将在2秒钟内淡出按钮视图,并使用线性曲线延迟0秒。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM