Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add ability for stationary pane to be transparent

  • Loading branch information...
commit 9a4fb647c9d27161cde0c38eb0831fbf8e070185 1 parent 80600b1
@jwilling authored
View
7 JWFolders/JWFolders.h
@@ -52,6 +52,13 @@ typedef NSInteger JWFoldersOpenDirection;
@property (nonatomic, readwrite) JWFoldersOpenDirection direction;
+/* Set whether the stationary folder pane should
+ * be transparent to show actual content underneath.
+ * The pane will still absorb touches, so your content
+ * will not recieve touch events. Defaults to NO. */
+@property (nonatomic, getter = isTransparentPane) BOOL transparentPane;
+
+
/* The following blocks are called at specific
* times during the lifetime of the folder.
*
View
29 JWFolders/JWFolders.m
@@ -22,7 +22,11 @@ - (void)createHighlightWithFrame:(CGRect)aFrame;
@end
@interface JWFolders ()
-- (JWFolderSplitView *)buttonForRect:(CGRect)aRect andScreen:(UIImage *)screen top:(BOOL)isTop position:(CGPoint)position;
+- (JWFolderSplitView *)buttonForRect:(CGRect)aRect
+ screen:(UIImage *)screen
+ position:(CGPoint)position
+ top:(BOOL)isTop
+ transparent:(BOOL)isTransparent;
- (void)openFolderWithContentView:(UIView *)contentView
position:(CGPoint)position
containerView:(UIView *)containerView
@@ -102,6 +106,8 @@ - (void)openFolderWithContentView:(UIView *)contentView
self.completionBlock = completionBlock;
self.direction = (direction > 0)?direction:JWFoldersOpenDirectionUp;
+ BOOL up = (direction == JWFoldersOpenDirectionUp);
+
UIImage *screenshot = [containerView screenshot];
CGFloat width = containerView.frame.size.width;
CGFloat height = containerView.frame.size.height;
@@ -109,8 +115,16 @@ - (void)openFolderWithContentView:(UIView *)contentView
CGRect upperRect = CGRectMake(0, 0, width, position.y);
CGRect lowerRect = CGRectMake(0, position.y, width, height - position.y);
- self.top = [self buttonForRect:upperRect andScreen:screenshot top:YES position:position];
- self.bottom = [self buttonForRect:lowerRect andScreen:screenshot top:NO position:position];
+ self.top = [self buttonForRect:upperRect
+ screen:screenshot
+ position:position
+ top:YES
+ transparent:up ? NO : self.isTransparentPane];
+ self.bottom = [self buttonForRect:lowerRect
+ screen:screenshot
+ position:position
+ top:NO
+ transparent:up ? self.isTransparentPane : NO];
[self.top addTarget:self action:@selector(performClose:) forControlEvents:UIControlEventTouchUpInside];
[self.bottom addTarget:self action:@selector(performClose:) forControlEvents:UIControlEventTouchUpInside];
@@ -123,7 +137,6 @@ - (void)openFolderWithContentView:(UIView *)contentView
[containerView addSubview:self.top];
[containerView addSubview:self.bottom];
- BOOL up = (direction == JWFoldersOpenDirectionUp);
CGRect viewFrame = self.contentView.frame;
CGFloat heightPosition = (height - position.y);
viewFrame.origin.y = (up) ? (height - viewFrame.size.height - heightPosition) : (position.y);
@@ -177,7 +190,11 @@ - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag {
}
}
-- (JWFolderSplitView *)buttonForRect:(CGRect)aRect andScreen:(UIImage *)screen top:(BOOL)isTop position:(CGPoint)position {
+- (JWFolderSplitView *)buttonForRect:(CGRect)aRect
+ screen:(UIImage *)screen
+ position:(CGPoint)position
+ top:(BOOL)isTop
+ transparent:(BOOL)isTransparent {
CGFloat scale = [[UIScreen mainScreen] scale];
CGFloat width = aRect.size.width;
CGFloat height = aRect.size.height;
@@ -189,7 +206,7 @@ - (JWFolderSplitView *)buttonForRect:(CGRect)aRect andScreen:(UIImage *)screen t
JWFolderSplitView *button = [[JWFolderSplitView alloc] initWithFrame:aRect];
[button setIsTopView:isTop];
button.position = position;
- button.layer.contents = (__bridge id)(ref1);
+ button.layer.contents = isTransparent ? nil : (__bridge id)(ref1);
button.layer.contentsGravity = kCAGravityCenter;
button.layer.contentsScale = scale;
CGImageRelease(ref1);
View
18 JWFoldersDemo/JWFoldersDemo/ViewController.m
@@ -38,14 +38,28 @@ - (IBAction)openFolderDown:(id)sender {
NSLog(@"Folder will open down.");
CGPoint openPoint = CGPointMake(0, CGRectGetHeight(self.view.frame) / 2); //arbitrary point
- //you can also open the folder this way
- //it could be potentially easier if you don't need the blocks
+ // you can also open the folder this way
+ // it could be potentially easier if you don't need the blocks
JWFolders *folder = [JWFolders folder];
folder.contentView = self.sampleFolder.view;
folder.containerView = self.view;
folder.position = openPoint;
folder.direction = JWFoldersOpenDirectionDown;
+ folder.transparentPane = YES;
[folder open];
+
+ // quick demo to demonstrate how the stationary pane is see-though
+ [UIView animateWithDuration:0.3f animations:^{
+ [(UIButton *)sender setTransform:CGAffineTransformRotate([(UIButton *)sender transform], M_PI*0.1f)];
+ } completion:^(BOOL finished) {
+ [UIView animateWithDuration:0.3f animations:^{
+ [(UIButton *)sender setTransform:CGAffineTransformRotate(CGAffineTransformIdentity, -M_PI*0.1f)];
+ } completion:^(BOOL finished) {
+ [UIView animateWithDuration:0.3f animations:^{
+ [(UIButton *)sender setTransform:CGAffineTransformIdentity];
+ }];
+ }];
+ }];
}
@end
Please sign in to comment.
Something went wrong with that request. Please try again.