Class: RubyMotionQuery::Stylers::UIViewStyler
- Inherits:
-
Object
- Object
- RubyMotionQuery::Stylers::UIViewStyler
show all
- Defined in:
- motion/ruby_motion_query/stylers/ui_view_styler.rb
Overview
When you create a styler, always inherit UIViewStyler
Instance Method Summary
(collapse)
Constructor Details
Returns a new instance of UIViewStyler
6
7
8
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 6
def initialize(view)
@view = view
end
|
Instance Method Details
- (Object) background_color
198
199
200
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 198
def background_color
@view.backgroundColor
end
|
- (Object) background_color=(value)
195
196
197
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 195
def background_color=(value)
@view.setBackgroundColor value
end
|
- (Object) background_image=(value)
202
203
204
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 202
def background_image=(value)
@view.setBackgroundColor UIColor.colorWithPatternImage(value)
end
|
122
123
124
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 122
def bottom
self.top + self.height
end
|
- (Object) bottom=(value)
119
120
121
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 119
def bottom=(value)
self.top = value - self.height
end
|
158
159
160
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 158
def center
@view.center
end
|
- (Object) center=(value)
155
156
157
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 155
def center=(value)
@view.center = value
end
|
- (Object) center_x
167
168
169
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 167
def center_x
@view.center.x
end
|
- (Object) center_x=(value)
162
163
164
165
166
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 162
def center_x=(value)
c = @view.center
c.x = value
@view.center = c
end
|
- (Object) center_y
176
177
178
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 176
def center_y
@view.center.y
end
|
- (Object) center_y=(value)
171
172
173
174
175
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 171
def center_y=(value)
c = @view.center
c.y = value
@view.setCenter c
end
|
- (Object) centered=(option)
param can be :horizontal, :vertical, :both
181
182
183
184
185
186
187
188
189
190
191
192
193
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 181
def centered=(option)
if parent = @view.superview
case option
when :horizontal
self.center_x = parent.bounds.size.width / 2
when :vertical
self.center_y = parent.bounds.size.height / 2
else
@view.center = [parent.bounds.size.width / 2, parent.bounds.size.height / 2]
end
end
end
|
- (Object) clips_to_bounds
265
266
267
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 265
def clips_to_bounds
@view.clipsToBounds
end
|
- (Object) clips_to_bounds=(value)
262
263
264
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 262
def clips_to_bounds=(value)
@view.setClipsToBounds value
end
|
- (Object) content_mode
258
259
260
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 258
def content_mode
@view.contentMode
end
|
- (Object) content_mode=(value)
255
256
257
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 255
def content_mode=(value)
@view.setContentMode value
end
|
230
231
232
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 230
def enabled
@view.enabled
end
|
- (Object) enabled=(value)
227
228
229
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 227
def enabled=(value)
@view.setEnabled value
end
|
56
57
58
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 56
def frame
@view.frame
end
|
- (Object) frame=(value)
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 39
def frame=(value)
if value == :full @view.frame = self.superview.bounds
elsif value.is_a?(Hash)
f = @view.frame
h = value
f.origin.x = h[:l] || h[:left] || f.origin.x
f.origin.y = h[:t] || h[:top] || f.origin.y
f.size.width = h[:w] || h[:width] || f.size.width
f.size.height =h[:h] || h[:height] || f.size.height
@view.frame = f
else
@view.frame = value
end
end
|
- (Object) from_bottom
131
132
133
134
135
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 131
def from_bottom
if superview = @view.superview
superview.bounds.size.height - self.top
end
end
|
- (Object) from_bottom=(value)
126
127
128
129
130
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 126
def from_bottom=(value)
if superview = @view.superview
self.top = superview.bounds.size.height - self.height - value
end
end
|
- (Object) from_right
149
150
151
152
153
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 149
def from_right
if superview = @view.superview
superview.bounds.size.width - self.left
end
end
|
- (Object) from_right=(value)
144
145
146
147
148
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 144
def from_right=(value)
if superview = @view.superview
self.left = superview.bounds.size.width - self.width - value
end
end
|
115
116
117
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 115
def height
@view.size.height
end
|
- (Object) height=(value)
110
111
112
113
114
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 110
def height=(value)
f = @view.frame
f.size.height = value
@view.frame = f
end
|
223
224
225
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 223
def hidden
@view.isHidden
end
|
- (Object) hidden=(value)
220
221
222
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 220
def hidden=(value)
@view.setHidden value
end
|
- (Object) left
Also known as:
x
86
87
88
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 86
def left
@view.origin.x
end
|
- (Object) left=(value)
81
82
83
84
85
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 81
def left=(value)
f = @view.frame
f.origin.x = value
@view.frame = f
end
|
216
217
218
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 216
def opaque
@view.layer.isOpaque
end
|
- (Object) opaque=(value)
213
214
215
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 213
def opaque=(value)
@view.layer.setOpaque value
end
|
- (Object) padded=(value)
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 60
def padded=(value)
if value.is_a?(Hash)
h = value
h[:l] ||= (h[:left] || 0)
h[:t] ||= (h[:top] || 0)
h[:r] ||= (h[:right] || 0)
h[:b] ||= (h[:bottom] || 0)
sbounds = self.superview.bounds
value = [
[h[:l], h[:t]],
[
sbounds.size.width - h[:l] - h[:r],
sbounds.size.height - h[:t] - h[:b]
]]
@view.frame = value
end
end
|
140
141
142
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 140
def right
self.left + self.width
end
|
- (Object) right=(value)
137
138
139
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 137
def right=(value)
self.left = value - self.width
end
|
- (Object) rotation=(new_angle)
250
251
252
253
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 250
def rotation=(new_angle)
radians = new_angle * Math::PI / 180
@view.transform = CGAffineTransformMakeRotation(radians)
end
|
- (Object) scale=(amount)
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 234
def scale=(amount)
if amount == 1.0
@view.transform = CGAffineTransformIdentity
else
if amount.is_a?(NSArray)
width = amount[0]
height = amount[1]
else
height = amount
width = amount
end
@view.transform = CGAffineTransformMakeScale(width, height)
end
end
|
- (Object) super_height
27
28
29
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 27
def super_height
@view.superview.frame.size.height
end
|
- (Object) super_width
31
32
33
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 31
def super_width
@view.superview.frame.size.width
end
|
- (Object) superview
Also known as:
parent
22
23
24
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 22
def superview
@view.superview || rmq(@view).view_controller.view || rmq.window
end
|
- (Object) tag(tags)
35
36
37
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 35
def tag(tags)
rmq(@view).tag(tags)
end
|
- (Object) top
Also known as:
y
96
97
98
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 96
def top
@view.origin.y
end
|
- (Object) top=(value)
91
92
93
94
95
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 91
def top=(value)
f = @view.frame
f.origin.y = value
@view.frame = f
end
|
14
15
16
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 14
def view
@view
end
|
- (Object) view=(value)
If a view is reset, all state should be reset as well
11
12
13
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 11
def view=(value)
@view = value
end
|
- (Boolean) view_has_been_styled?
18
19
20
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 18
def view_has_been_styled?
!@view.rmq_data.style_name.nil?
end
|
106
107
108
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 106
def width
@view.size.width
end
|
- (Object) width=(value)
101
102
103
104
105
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 101
def width=(value)
f = @view.frame
f.size.width = value
@view.frame = f
end
|
- (Object) z_position
209
210
211
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 209
def z_position
@view.layer.zPosition
end
|
- (Object) z_position=(index)
206
207
208
|
# File 'motion/ruby_motion_query/stylers/ui_view_styler.rb', line 206
def z_position=(index)
@view.layer.setZPosition index
end
|