@@ -19,22 +19,18 @@ @interface IISideController ()
19
19
20
20
@end
21
21
22
- @implementation IISideController {
23
- CGFloat _constrainedSize;
24
- }
22
+ @implementation IISideController
25
23
26
24
- (id )initWithViewController : (UIViewController*)controller constrained : (CGFloat )constrainedSize {
27
25
if ((self = [super initWithViewController: controller])) {
28
26
_constrainedSize = constrainedSize;
29
- _animatedShrink = NO ;
30
27
}
31
28
return self;
32
29
}
33
30
34
31
- (id )initWithViewController : (UIViewController*)controller {
35
32
if ((self = [super initWithViewController: controller])) {
36
33
_constrainedSize = -1 ;
37
- _animatedShrink = NO ;
38
34
}
39
35
return self;
40
36
}
@@ -46,26 +42,40 @@ - (void)viewDidLoad {
46
42
47
43
- (void )viewWillAppear : (BOOL )animated {
48
44
[super viewWillAppear: animated];
49
- [CATransaction begin ];
50
- if (!self.animatedShrink ) {
51
- [CATransaction setValue: (id )kCFBooleanTrue forKey: kCATransactionDisableActions ];
52
- }
45
+
53
46
self.view .backgroundColor = self.wrappedController .view .backgroundColor ;
54
- [CATransaction commit ];
55
- [self shrinkSide ];
47
+ [self shrinkSideAnimated: animated];
56
48
}
57
49
58
50
- (void )willAnimateRotationToInterfaceOrientation : (UIInterfaceOrientation)toInterfaceOrientation duration : (NSTimeInterval )duration {
59
51
[super willAnimateRotationToInterfaceOrientation: toInterfaceOrientation duration: duration];
60
- [self shrinkSide ];
52
+ [self shrinkSideAnimated: YES ];
53
+ }
54
+
55
+ - (void )setConstrainedSize : (CGFloat )constrainedSize {
56
+ [self setConstrainedSize: constrainedSize animated: YES ];
57
+ }
58
+
59
+ - (void )setConstrainedSize : (CGFloat )constrainedSize animated : (BOOL )animated {
60
+ _constrainedSize = constrainedSize;
61
+ [self shrinkSideAnimated: animated];
61
62
}
62
63
63
64
- (void )shrinkSide {
65
+ [self shrinkSideAnimated: YES ];
66
+ }
67
+
68
+ - (void )shrinkSideAnimated : (BOOL )animated {
64
69
if (self.viewDeckController ) {
65
70
// we don't want this animated
66
71
[CATransaction begin ];
67
- if (!self.animatedShrink ) {
68
- [CATransaction setValue: (id )kCFBooleanTrue forKey: kCATransactionDisableActions ];
72
+ if (animated) {
73
+ [UIView beginAnimations: @" shrinkSide" context: nil ];
74
+ [UIView setAnimationDuration: 0.3 ];
75
+ [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
76
+ }
77
+ else {
78
+ [CATransaction disableActions ];
69
79
}
70
80
71
81
if (self.viewDeckController .leftController == self) {
@@ -85,8 +95,20 @@ - (void)shrinkSide {
85
95
self.wrappedController .view .frame = II_CGRectOffsetTopAndShrink (self.view .bounds , offset);
86
96
}
87
97
98
+ if (animated) {
99
+ [UIView commitAnimations ];
100
+ }
88
101
[CATransaction commit ];
89
102
}
90
103
}
91
104
92
105
@end
106
+
107
+
108
+ @implementation UIViewController (IISideController)
109
+
110
+ - (IISideController*)sideController {
111
+ return (IISideController*)self.wrapController ;
112
+ }
113
+
114
+ @end
0 commit comments