UWP C# 禁用方向更改动画 [英] UWP C# Disable Orientation Change Animation

查看:24
本文介绍了UWP C# 禁用方向更改动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以禁用手机旋转改变时执行的屏幕旋转"动画(从横向到纵向,反之亦然)?

Is it possible to disable the 'screen rotating' animation that is executed when phone's rotation changes (from landscape to portrait or vice versa)?

推荐答案

你需要使用 DisplayInformation.AutoRotationPreferences = DisplayOrientations.LandscapeFlipped |DisplayOrientations.Landscape;

您需要在页面的 OnNavigatedTo 中设置方向,您可以根据页面或要求启用或禁用不同的方向.

you need to set the orientation in OnNavigatedTo of you pages, you can enable or disable different orientations depending of your pages or your requirements.

更新:如果你想像相机应用一样旋转按钮,动画流畅,有一些方法可以做到:

Update: If you want to rotate the buttons like the Camera app with a smooth animation there are some ways to do:

1.- 使用陀螺仪:

您需要使用情节提要根据设备的位置实时移动按钮的旋转来创建自己的动画.您需要进行一些计算以确定设备是处于纵向模式还是横向模式,并像诺基亚相机一样实时移动按钮.

You need to create your own animation with storyboards moving rotation of the buttons in realtime according of the position of the device. you will need to do some calculations to determine if the device is in portrait or landscape mode and move the buttons in realtime like Nokia Camera.

我在 Windows Phone 8 上做了这个方法,这很困难,但最终的工作非常好!https://msdn.microsoft.com/library/windows/apps/br225718

I did this approach for Windows Phone 8 it's very hard but the final work It was very good! https://msdn.microsoft.com/library/windows/apps/br225718

2.- 使用 OrientationChanged 事件

2.- using OrientationChanged event

您需要侦听事件 OrientationChanged 事件并且对设备的厌恶立即处于纵向或横向模式您需要对要旋转的控件执行一些动画您可以使用 Blend 和 StoryBoards 执行此方法https://msdn.microsoft.com/en-us/library/windows/apps/windows.graphics.display.displayproperties.orientationchanged.aspx

you need to listen the event OrientationChanged event and detest of the device is in portrait or landscape mode immediate you will need to execute some animations to your controls to be rotated you can do this approach using Blend and StoryBoards https://msdn.microsoft.com/en-us/library/windows/apps/windows.graphics.display.displayproperties.orientationchanged.aspx

这是一个创建简单动画来旋转图像的示例

Here is an example to create a easy animation to rotate an image

https://comentsys.wordpress.com/2015/05/06/windows-10-universal-windows-platform-image-rotate/

这两个选项之间的最大区别在于,第一个选项提供了很好的体验,您可以根据设备的方向实时更改控件,而第二种方法是在引发事件后执行动画.

The big difference between the two options is in the first option you offer a nice experience in real time changing the controls depending of the orientation of the device with the second approach after the event is raised you will execute the animation.

最好的问候

如果对您有用,请标记此答案!

Please mark this answer if it's useful for you!

这篇关于UWP C# 禁用方向更改动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆