forked from NativeScript/NativeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ios.ts
More file actions
54 lines (43 loc) · 1.71 KB
/
utils.ios.ts
File metadata and controls
54 lines (43 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import {View} from "ui/core/view";
import * as utils from "utils/utils";
export module ios {
export function getActualHeight(view: UIView): number {
if (view.window && !view.hidden) {
return view.frame.size.height;
}
return 0;
}
export function getStatusBarHeight(): number {
var app = UIApplication.sharedApplication();
if (!app || app.statusBarHidden) {
return 0;
}
var statusFrame = app.statusBarFrame;
return Math.min(statusFrame.size.width, statusFrame.size.height);
}
export function _layoutRootView(rootView: View, parentBounds: CGRect) {
if (!rootView || !parentBounds) {
return;
}
let size = parentBounds.size;
let width = size.width;
let height = size.height;
var superview = (<UIView>rootView._nativeView).superview;
var superViewRotationRadians;
if (superview) {
superViewRotationRadians = atan2f(superview.transform.b, superview.transform.a);
}
if (utils.ios.MajorVersion < 8 && utils.ios.isLandscape() && !superViewRotationRadians) {
// in iOS 7 when in landscape we switch width with height because on device they don't change even when rotated.
width = size.height;
height = size.width;
}
var origin = parentBounds.origin;
var left = origin.x;
var top = origin.y;
var widthSpec = utils.layout.makeMeasureSpec(width, utils.layout.EXACTLY);
var heightSpec = utils.layout.makeMeasureSpec(height, utils.layout.EXACTLY);
rootView.measure(widthSpec, heightSpec);
rootView.layout(left, top, width, height);
}
}