Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Exposed constrainedSize property and shrinkSide methods in IISideCont…

…roller.

Allows to manually trigger the resizing of the side controller when the ledge side of a IIViewDeckController is triggered.

You can change the constrainedSize (-1: use ledge value from viewdeckcontroller) or just trigger the resize using the method calls. Changing the property will automatically shrink.
  • Loading branch information...
commit 02034e35d23f3134ecc7592fdb50c98dcd4030ef 1 parent 003a2ce
@Inferis Inferis authored
View
2  VERSION
@@ -1 +1 @@
-2.2.3
+2.2.4
View
4 ViewDeck.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'ViewDeck'
- s.version = '2.2.3'
+ s.version = '2.2.4'
s.platform = :ios
s.summary = 'An implementation of the sliding functionality found in the ' \
'Path 2.0 or Facebook iOS apps.'
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
}
s.author = { 'Tom Adriaenssen' => 'http://codedump.blergh.be/' }
s.source = { :git => 'https://github.com/Inferis/ViewDeck.git',
- :tag => '2.2.3'}
+ :tag => '2.2.4'}
s.source_files = 'ViewDeck/*.{h,m}'
s.frameworks = 'QuartzCore'
end
View
14 ViewDeck/IISideController.h
@@ -10,8 +10,20 @@
@interface IISideController : IIWrapController
-@property (nonatomic, assign) BOOL animatedShrink; // if the shrink action should participate in any ongoing animation. Defaults to NO.
+@property (nonatomic, assign) CGFloat constrainedSize;
- (id)initWithViewController:(UIViewController*)controller constrained:(CGFloat)constrainedSize;
+- (void)shrinkSide;
+- (void)shrinkSideAnimated:(BOOL)animated;
+
@end
+
+
+// category on UIViewController to provide access to the sideController in the
+// contained viewcontrollers, a la UINavigationController.
+@interface UIViewController (IISideController)
+
+@property(nonatomic,readonly,retain) IISideController *sideController;
+
+@end
View
50 ViewDeck/IISideController.m
@@ -19,14 +19,11 @@ @interface IISideController ()
@end
-@implementation IISideController {
- CGFloat _constrainedSize;
-}
+@implementation IISideController
- (id)initWithViewController:(UIViewController*)controller constrained:(CGFloat)constrainedSize {
if ((self = [super initWithViewController:controller])) {
_constrainedSize = constrainedSize;
- _animatedShrink = NO;
}
return self;
}
@@ -34,7 +31,6 @@ - (id)initWithViewController:(UIViewController*)controller constrained:(CGFloat)
- (id)initWithViewController:(UIViewController*)controller {
if ((self = [super initWithViewController:controller])) {
_constrainedSize = -1;
- _animatedShrink = NO;
}
return self;
}
@@ -46,26 +42,40 @@ - (void)viewDidLoad {
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
- [CATransaction begin];
- if (!self.animatedShrink) {
- [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
- }
+
self.view.backgroundColor = self.wrappedController.view.backgroundColor;
- [CATransaction commit];
- [self shrinkSide];
+ [self shrinkSideAnimated:animated];
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
- [self shrinkSide];
+ [self shrinkSideAnimated:YES];
+}
+
+- (void)setConstrainedSize:(CGFloat)constrainedSize {
+ [self setConstrainedSize:constrainedSize animated:YES];
+}
+
+- (void)setConstrainedSize:(CGFloat)constrainedSize animated:(BOOL)animated {
+ _constrainedSize = constrainedSize;
+ [self shrinkSideAnimated:animated];
}
- (void)shrinkSide {
+ [self shrinkSideAnimated:YES];
+}
+
+- (void)shrinkSideAnimated:(BOOL)animated {
if (self.viewDeckController) {
// we don't want this animated
[CATransaction begin];
- if (!self.animatedShrink) {
- [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
+ if (animated) {
+ [UIView beginAnimations:@"shrinkSide" context:nil];
+ [UIView setAnimationDuration:0.3];
+ [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
+ }
+ else {
+ [CATransaction disableActions];
}
if (self.viewDeckController.leftController == self) {
@@ -85,8 +95,20 @@ - (void)shrinkSide {
self.wrappedController.view.frame = II_CGRectOffsetTopAndShrink(self.view.bounds, offset);
}
+ if (animated) {
+ [UIView commitAnimations];
+ }
[CATransaction commit];
}
}
@end
+
+
+@implementation UIViewController (IISideController)
+
+- (IISideController*)sideController {
+ return (IISideController*)self.wrapController;
+}
+
+@end

0 comments on commit 02034e3

Please sign in to comment.
Something went wrong with that request. Please try again.