mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Add support for 'px' on Length in iOS
This commit is contained in:
@@ -5,6 +5,8 @@ import {
|
||||
|
||||
export * from "./utils-common";
|
||||
|
||||
let mainScreenScale;
|
||||
|
||||
function isOrientationLandscape(orientation: number) {
|
||||
return orientation === UIDeviceOrientation.LandscapeLeft || orientation === UIDeviceOrientation.LandscapeRight;
|
||||
}
|
||||
@@ -18,15 +20,15 @@ export module layout {
|
||||
}
|
||||
|
||||
export function getDisplayDensity(): number {
|
||||
return 1;
|
||||
return mainScreenScale;
|
||||
}
|
||||
|
||||
export function toDevicePixels(value: number): number {
|
||||
return value * getDisplayDensity();
|
||||
return value * mainScreenScale;
|
||||
}
|
||||
|
||||
export function toDeviceIndependentPixels(value: number): number {
|
||||
return value / getDisplayDensity();
|
||||
return value / mainScreenScale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,4 +121,6 @@ class UIDocumentInteractionControllerDelegateImpl extends NSObject implements UI
|
||||
public documentInteractionControllerRectForPreview(controller: UIDocumentInteractionController): CGRect {
|
||||
return this.getViewController().view.frame;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mainScreenScale = ios.getter(UIScreen, UIScreen.mainScreen).scale;
|
||||
Reference in New Issue
Block a user