/
first_controller.rb
50 lines (37 loc) · 1.63 KB
/
first_controller.rb
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
class FirstController < UIViewController
def viewDidLoad
@typewriter = TypewriterView.alloc.initWithFrame([[0, 0], [320, 400]])
self.view.addSubview(@typewriter)
blue_view = UIView.alloc.initWithFrame([[0, 0], [ 80, 80]])
blue_view.backgroundColor = UIColor.blueColor
red_view = UIView.alloc.initWithFrame([[0, 0], [120, 120]])
red_view.backgroundColor = UIColor.redColor
green_view = UIView.alloc.initWithFrame([[0, 0], [120, 40]])
green_view.backgroundColor = UIColor.greenColor
cyan_view = UIView.alloc.initWithFrame([[0, 0], [120, 40]])
cyan_view.backgroundColor = UIColor.cyanColor
green_cyan_combo = TypewriterView.alloc.initWithFrame([[0, 0], [120, 120]])
green_cyan_combo.addSubview(green_view)
green_cyan_combo.addSubview(cyan_view)
gray_view = UIView.alloc.initWithFrame([[0, 0], [80, 240]])
gray_view.backgroundColor = UIColor.grayColor
white_view = UIView.alloc.initWithFrame([[0, 0], [80, 120]])
white_view.backgroundColor = UIColor.whiteColor
black_view = UIView.alloc.initWithFrame([[0, 0], [80, 180]])
black_view.backgroundColor = UIColor.blackColor
bw_view = TypewriterView.alloc.initWithFrame([[]])
[blue_view, red_view, green_cyan_combo, gray_view].each { |view|
@typewriter.addSubview(view)
}
end
def shouldAutorotateToInterfaceOrientation(orientation)
true
end
def willAnimateRotationToInterfaceOrientation(orientation, duration:duration)
bframe = @typewriter.frame
w, h = bframe.size.width, bframe.size.height
bframe.size = h, w
@typewriter.frame = bframe
@typewriter.setNeedsLayout
end
end