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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/uikit/motion_browser.rb', line 5
def init
super
setBackgroundColor UIColor.whiteColor
addSubview(@webview = UIWebView.new)
addSubview(@toolbar = MotionBrowserToolbar.new)
@delegate = @toolbar.delegate = MotionBrowserToolbarDelegate.new(@webview)
@webview.translatesAutoresizingMaskIntoConstraints = false
@toolbar.translatesAutoresizingMaskIntoConstraints = false
attributes = []
attributes << NSLayoutConstraint.constraintWithItem(
@webview,
attribute: NSLayoutAttributeTop,
relatedBy: NSLayoutRelationEqual,
toItem: self,
attribute: NSLayoutAttributeTop,
multiplier: 1,
constant: 0
)
attributes << NSLayoutConstraint.constraintWithItem(
@webview,
attribute: NSLayoutAttributeBottom,
relatedBy: NSLayoutRelationEqual,
toItem: self,
attribute: NSLayoutAttributeBottom,
multiplier: 1,
constant: 0
)
attributes << NSLayoutConstraint.constraintWithItem(
@webview,
attribute: NSLayoutAttributeLeft,
relatedBy: NSLayoutRelationEqual,
toItem: self,
attribute: NSLayoutAttributeLeft,
multiplier: 1,
constant: 0
)
attributes << NSLayoutConstraint.constraintWithItem(
@webview,
attribute: NSLayoutAttributeRight,
relatedBy: NSLayoutRelationEqual,
toItem: self,
attribute: NSLayoutAttributeRight,
multiplier: 1,
constant: 0
)
attributes << NSLayoutConstraint.constraintWithItem(
@toolbar,
attribute: NSLayoutAttributeHeight,
relatedBy: NSLayoutRelationEqual,
toItem: nil,
attribute: NSLayoutAttributeNotAnAttribute,
multiplier: 1,
constant: 50
)
attributes << NSLayoutConstraint.constraintWithItem(
@toolbar,
attribute: NSLayoutAttributeBottom,
relatedBy: NSLayoutRelationEqual,
toItem: self,
attribute: NSLayoutAttributeBottom,
multiplier: 1,
constant: 0
)
attributes << NSLayoutConstraint.constraintWithItem(
@toolbar,
attribute: NSLayoutAttributeLeft,
relatedBy: NSLayoutRelationEqual,
toItem: self,
attribute: NSLayoutAttributeLeft,
multiplier: 1,
constant: 0
)
attributes << NSLayoutConstraint.constraintWithItem(
@toolbar,
attribute: NSLayoutAttributeRight,
relatedBy: NSLayoutRelationEqual,
toItem: self,
attribute: NSLayoutAttributeRight,
multiplier: 1,
constant: 0
)
addConstraints(attributes)
self
end
|