以Xamarin形式旋转的360度图像

xam*_*rin 4 c# xaml xamarin xamarin.forms

在Xamarin Forms中,我想将图像旋转为360度.此图像在运行时不断旋转动画.此外,此图像有6个版本的不同视图.想想就像用手旋转玻璃一样.

我试试这个,但没用:

<Image Source="glass.png" RotateToY="30"/>
Run Code Online (Sandbox Code Playgroud)

Sus*_*ver 8

您可以使用图像"旋转"属性并根据需要通过后台线程进行更改,并通过其添加动画RotateTo来控制旋转速度和起点/终点速度:

async Task RotateImageContinously()
{
    while (true) // a CancellationToken in real life ;-)
    {
        for (int i = 1; i < 7; i++)
        {
            if (image.Rotation >= 360f) image.Rotation = 0;
            await image.RotateTo(i * (360 / 6), 1000, Easing.CubicInOut);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

弹跳:

在此输入图像描述

线性:

在此输入图像描述

立方体:

在此输入图像描述