apply bottom and right safe area inset to views

This commit is contained in:
Martin Yankov
2018-08-17 13:50:34 +03:00
parent 496ccb4acf
commit 35ad8ba3b0

View File

@@ -256,13 +256,13 @@ export class View extends ViewCommon {
return { left, right, top, bottom };
}
public getFrameFromPosition(position: { left, top, right, bottom }, insets?: { left, top }): CGRect {
insets = insets || { left: 0, top: 0 };
public getFrameFromPosition(position: { left, top, right, bottom }, insets?: { left, top, right, bottom }): CGRect {
insets = insets || { left: 0, top: 0, right: 0, bottom: 0 };
const left = layout.round(layout.toDeviceIndependentPixels(position.left + insets.left));
const top = layout.round(layout.toDeviceIndependentPixels(position.top + insets.top));
const width = layout.round(layout.toDeviceIndependentPixels(position.right - position.left));
const height = layout.round(layout.toDeviceIndependentPixels(position.bottom - position.top));
const width = layout.round(layout.toDeviceIndependentPixels(position.right - position.left - insets.left - insets.right));
const height = layout.round(layout.toDeviceIndependentPixels(position.bottom - position.top - insets.top - insets.bottom));
return CGRectMake(left, top, width, height);
}