Add support for 'px' on Length in iOS

This commit is contained in:
Panayot Cankov
2017-03-06 13:19:57 +02:00
parent b45cbe929b
commit 9f1ebc11ca
10 changed files with 37 additions and 31 deletions

View File

@@ -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;