如何在Xamarin元素中从一种颜色慢慢变为另一种颜色?

时间:2020-11-06 13:47:50

标签: xamarin xamarin.forms

我创建了一个简单的模板,点击该模板可将颜色更改为红色5000ms。

有人知道我是否可以更改它,以便它可以使用Xamarin的动画功能从“默认”缓慢变为“红色”,然后返回?

public class LinkTemplate : Grid
{
    public LinkTemplate()
    {
        TapGestureRecognizer tap2 = new TapGestureRecognizer().BindAction( t =>
            t.Tapped += async (s, e) => {
                this.BackgroundColor = Color.Red;
                await Task.Delay(5000);
                this.BackgroundColor = Color.Yellow;
            }
        );
        GestureRecognizers.Add(tap2);
    }
}

0 个答案:

没有答案