Skip to content

Commit

Permalink
merged with master
Browse files Browse the repository at this point in the history
  • Loading branch information
honcheng committed Dec 25, 2012
2 parents 3f44aa5 + 1abef49 commit 5053464
Show file tree
Hide file tree
Showing 8 changed files with 221 additions and 91 deletions.
1 change: 1 addition & 0 deletions PaperFold/PaperFold/DemoRootViewController.m
Expand Up @@ -109,6 +109,7 @@ - (id)init

#warning disabling scroll, requires tapping cell twice to select cells. to be fixed
[_centerTableView setScrollEnabled:NO];
//[_paperFoldView setEnableHorizontalEdgeDragging:YES];
}
return self;
}
Expand Down
33 changes: 20 additions & 13 deletions PaperFold/PaperFold/PaperFold/MultiFoldView.m
Expand Up @@ -85,7 +85,7 @@ - (id)initWithFrame:(CGRect)frame folds:(int)folds pullFactor:(float)factor

- (void)setContent:(UIView *)contentView
{
if ([contentView isKindOfClass:[MKMapView class]]) _shouldTakeScreenshotBeforeUnfolding = YES;
if ([contentView isKindOfClass:NSClassFromString(@"MKMapView")]) _shouldTakeScreenshotBeforeUnfolding = YES;

// set the content view
self.contentViewHolder = [[UIView alloc] initWithFrame:CGRectMake(0,0,contentView.frame.size.width,contentView.frame.size.height)];
Expand Down Expand Up @@ -128,15 +128,19 @@ - (void)setScreenshotImage:(UIImage*)image
for (int i=0; i<self.numberOfFolds; i++)
{
CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], CGRectMake(foldWidth*i*image.scale, 0, foldWidth*image.scale, image.size.height*image.scale));
UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];
CFRelease(imageRef);
FoldView *foldView = nil;
if (self.foldDirection==FoldDirectionHorizontalLeftToRight) {
foldView = (FoldView*)[self viewWithTag:FOLDVIEW_TAG + (self.numberOfFolds - 1) - i];
} else {
foldView = (FoldView*)[self viewWithTag:FOLDVIEW_TAG+i];
if (imageRef)
{
UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];
CFRelease(imageRef);
FoldView *foldView = nil;
if (self.foldDirection==FoldDirectionHorizontalLeftToRight) {
foldView = (FoldView*)[self viewWithTag:FOLDVIEW_TAG + (self.numberOfFolds - 1) - i];
} else {
foldView = (FoldView*)[self viewWithTag:FOLDVIEW_TAG+i];
}
[foldView setImage:croppedImage];
}
[foldView setImage:croppedImage];

}
}
else if (self.foldDirection==FoldDirectionVertical)
Expand All @@ -145,10 +149,13 @@ - (void)setScreenshotImage:(UIImage*)image
for (int i=0; i<self.numberOfFolds; i++)
{
CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], CGRectMake(0, foldHeight*(self.numberOfFolds-i-1)*image.scale, image.size.width*image.scale, foldHeight*image.scale));
UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];
CFRelease(imageRef);
FoldView *foldView = (FoldView*)[self viewWithTag:FOLDVIEW_TAG+i];
[foldView setImage:croppedImage];
if (imageRef)
{
UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];
CFRelease(imageRef);
FoldView *foldView = (FoldView*)[self viewWithTag:FOLDVIEW_TAG+i];
[foldView setImage:croppedImage];
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions PaperFold/PaperFold/PaperFold/PaperFoldConstants.h
Expand Up @@ -14,6 +14,7 @@
#define kRightViewUnfoldThreshold 0.3
#define kTopViewUnfoldThreshold 0.3
#define kBottomViewUnfoldThreshold 0.3
#define kEdgeScrollWidth 40.0

typedef enum
{
Expand Down
13 changes: 12 additions & 1 deletion PaperFold/PaperFold/PaperFold/PaperFoldView.h
Expand Up @@ -49,7 +49,7 @@ typedef void (^CompletionBlock)();
- (void)paperFoldView:(id)paperFoldView viewDidOffset:(CGPoint)offset;
@end

@interface PaperFoldView : UIView <MultiFoldViewDelegate>
@interface PaperFoldView : UIView <MultiFoldViewDelegate, UIGestureRecognizerDelegate>

// main content view
@property (nonatomic, strong) TouchThroughUIView *contentView;
Expand All @@ -68,6 +68,7 @@ typedef void (^CompletionBlock)();
@property (nonatomic, assign) PaperFoldState state, lastState;
// enable and disable dragging
@property (nonatomic, assign) BOOL enableLeftFoldDragging, enableRightFoldDragging, enableTopFoldDragging, enableBottomFoldDragging;
@property (nonatomic, assign) BOOL enableHorizontalEdgeDragging;
// indicate if the fold was triggered by finger panning, or set state
@property (nonatomic, assign) BOOL isAutomatedFolding;
@property (nonatomic, assign) id<PaperFoldViewDelegate> delegate;
Expand All @@ -76,6 +77,16 @@ typedef void (^CompletionBlock)();
// optimized screenshot follows the scale of the screen
// non-optimized is always the non-retina image
@property (nonatomic, assign) BOOL useOptimizedScreenshot;
// restrict the dragging gesture recogniser to a certain UIRect of this view. Useful to restrict
// dragging to, say, a navigation bar.
@property (nonatomic, assign) CGRect restrictedDraggingRect;
// divider lines
// these are exposed so that it is possible to hide the lines
// especially when views have rounded corners
@property (nonatomic, weak) UIView *leftDividerLine;
@property (nonatomic, weak) UIView *rightDividerLine;
@property (nonatomic, weak) UIView *topDividerLine;
@property (nonatomic, weak) UIView *bottomDividerLine;

// animate folding and unfolding when sent the offset of contentView
// offset are either sent from pan gesture recognizer, or manual animation done with NSTimer after gesture ended
Expand Down

0 comments on commit 5053464

Please sign in to comment.