Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add storyboard IB support #77

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions PaperFold/PaperFold/PaperFold/MultiFoldView.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ - (void)setFrame:(CGRect)frame
float foldWidth = frame.size.width/self.numberOfFolds;
FoldView *foldView = [[FoldView alloc] initWithFrame:CGRectMake(foldWidth*i,0,foldWidth,frame.size.height) foldDirection:_foldDirection];
[foldView setTag:FOLDVIEW_TAG+i];
[foldView setHidden:!self.contentViewHolder.hidden];
[self addSubview:foldView];
}
else if (_foldDirection==FoldDirectionVertical)
{
float foldHeight = frame.size.height/self.numberOfFolds;
FoldView *foldView = [[FoldView alloc] initWithFrame:CGRectMake(0,foldHeight*(self.numberOfFolds-i)-foldHeight,frame.size.width,foldHeight) foldDirection:_foldDirection];
[foldView setTag:FOLDVIEW_TAG+i];
[foldView setHidden:!self.contentViewHolder.hidden];
[self addSubview:foldView];
}
}
Expand Down
3 changes: 3 additions & 0 deletions PaperFold/PaperFold/PaperFold/PaperFoldNavigationController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#import "PaperFoldView.h"

@interface PaperFoldNavigationController : UIViewController <PaperFoldViewDelegate>
@property (nonatomic, copy, readonly) NSString *rootViewControllerID, *leftViewControllerID, *rightViewControllerID;
@property (nonatomic, copy, readonly) NSNumber *leftViewWidth;
@property (nonatomic, copy, readonly) NSNumber *rightViewWidth, *rightViewFoldCount, *rightViewPullFactor;
@property (nonatomic, strong) UIViewController *rootViewController, *leftViewController, *rightViewController;
@property (nonatomic, strong) PaperFoldView *paperFoldView;
- (id)initWithRootViewController:(UIViewController*)rootViewController;
Expand Down
32 changes: 31 additions & 1 deletion PaperFold/PaperFold/PaperFold/PaperFoldNavigationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,36 @@ @interface PaperFoldNavigationController ()

@implementation PaperFoldNavigationController

- (void)awakeFromNib {
[super awakeFromNib];

if (self.rootViewControllerID) {
self.rootViewController = [self.storyboard instantiateViewControllerWithIdentifier:self.rootViewControllerID];
[self initWithRootViewController:self.rootViewController];
}
if (self.leftViewControllerID) {
int leftWidth = 150;

if (self.leftViewWidth) leftWidth = [self.leftViewWidth intValue];

self.leftViewController = [self.storyboard instantiateViewControllerWithIdentifier:self.leftViewControllerID];
[self setLeftViewController:self.leftViewController width:leftWidth];
}
if (self.rightViewControllerID) {
int rightWidth = 250;
int rightFoldCount = 3;
float rightPullFactor = .9f;

if (self.rightViewWidth) rightWidth = [self.rightViewWidth intValue];
if (self.rightViewFoldCount) rightFoldCount = [self.rightViewFoldCount intValue];
if (self.rightViewPullFactor) rightPullFactor = [self.rightViewPullFactor floatValue];

self.rightViewController = [self.storyboard instantiateViewControllerWithIdentifier:self.rightViewControllerID];
[self setRightViewController:self.rightViewController width:rightWidth rightViewFoldCount:rightFoldCount rightViewPullFactor:rightPullFactor];
}

}

- (id)initWithRootViewController:(UIViewController*)rootViewController
{
self = [super init];
Expand All @@ -39,7 +69,7 @@ - (void)setRightViewController:(UIViewController*)rightViewController width:(flo
_rightViewController = rightViewController;

[self.rightViewController.view setFrame:CGRectMake(0,0,width,[self.view bounds].size.height)];
[self.paperFoldView setRightFoldContentView:self.rightViewController.view foldCount:rightViewFoldCount pullFactor:rightViewFoldCount];
[self.paperFoldView setRightFoldContentView:self.rightViewController.view foldCount:rightViewFoldCount pullFactor:rightViewPullFactor];
}

- (void)setLeftViewController:(UIViewController *)leftViewController width:(float)width
Expand Down
4 changes: 4 additions & 0 deletions PaperFold/PaperFold/PaperFold/PaperFoldView.m
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,8 @@ - (void)unfoldLeftView:(NSTimer*)timer
[self.bottomFoldView setHidden:YES];
[self.leftFoldView setHidden:NO];
[self.rightFoldView setHidden:NO];

self.paperFoldInitialPanDirection = PaperFoldInitialPanDirectionHorizontal;

CGAffineTransform transform = [self.contentView transform];
float x = transform.tx + (self.leftFoldView.frame.size.width-transform.tx)/4;
Expand Down Expand Up @@ -661,6 +663,8 @@ - (void)unfoldRightView:(NSTimer*)timer
[self.leftFoldView setHidden:NO];
[self.rightFoldView setHidden:NO];

self.paperFoldInitialPanDirection = PaperFoldInitialPanDirectionHorizontal;

CGAffineTransform transform = [self.contentView transform];
float x = transform.tx - (transform.tx+self.rightFoldView.frame.size.width)/8;
transform = CGAffineTransformMakeTranslation(x, 0);
Expand Down