【发布时间】:2011-03-25 07:37:24
【问题描述】:
我需要使用 MonoTouch 获取 iPhone/iPad 的宽度和高度。
如何以编程方式获取?
【问题讨论】:
标签: c# iphone ipad xamarin.ios resolution
我需要使用 MonoTouch 获取 iPhone/iPad 的宽度和高度。
如何以编程方式获取?
【问题讨论】:
标签: c# iphone ipad xamarin.ios resolution
要获取设备的屏幕尺寸,请致电UIScreen.MainScreen.Bounds。它返回带有屏幕大小的RectangleF。
【讨论】:
要使用宽度,
UIScreen.MainScreen.Bounds.Width
要使用高度,
UIScreen.MainScreen.Bounds.Height
【讨论】:
您使用 UIScreen.MainScreen.Bounds 来获取屏幕的 point 大小。 它返回屏幕的点值,而不是像素大小。
UIScreen.MainScreen.Scale 对于非视网膜显示器每点返回 1.0 像素,对于视网膜显示器每点返回 2.0 像素。
UIScreen.MainScreen.Bounds.Size.Width * UIScreen.MainScreen.Scale 将获得宽度(以像素为单位)。
【讨论】: