360 degree image rotating in Xamarin Forms

后端 未结 3 466
一生所求
一生所求 2021-01-19 22:55

In Xamarin Forms, I want to rotate an image as 360 degree. This image rotates with animation constantly at run time. Also, this image has 6 versions of different views. Thin

3条回答
  •  自闭症患者
    2021-01-19 23:25

    You can use the Image "Rotation" property and change it via a background thread if needed and add animate to it via RotateTo in order to control the rotation speed and start/end point speeds:

    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);
            }
        }
    }
    

    Bounce:

    Linear:

    Cubic:

提交回复
热议问题