Permalink
Browse files

add shouldRasterizeContent property

  • Loading branch information...
jwilling committed Aug 13, 2012
1 parent b212708 commit 87ec52c2d69a1dbd74203e2503d248143f39bd8f
Showing with 30 additions and 21 deletions.
  1. +16 −10 JWFolders/JWFolders.h
  2. +14 −11 JWFolders/JWFolders.m
View
@@ -1,4 +1,4 @@
-/*
+/*
Copyright (c) 2011, Jonathan Willing
All rights reserved.
Licensed under the BSD License.
@@ -23,16 +23,16 @@ typedef NSInteger JWFoldersOpenDirection;
@interface JWFolders : NSObject
-/* The view to be embedded between
- * two folder-style panels.
+/* The view to be embedded between
+ * two folder-style panels.
*
* REQUIRED */
@property (nonatomic, strong) UIView *contentView;
-/* This is the view in which you wish the folders to be
- * added as a subview of. Behaviour when the container
- * view is smaller than the content view is undefined.
+/* This is the view in which you wish the folders to be
+ * added as a subview of. Behaviour when the container
+ * view is smaller than the content view is undefined.
*
* REQUIRED */
@property (nonatomic, strong) UIView *containerView;
@@ -41,7 +41,7 @@ typedef NSInteger JWFoldersOpenDirection;
/* The position is used to determine where the folders should
* be opened. In later updates the x-coordinate will be used
* to create a "notch", similar to the iOS Springboard. The
- * position should be relative to the container view.
+ * position should be relative to the container view.
*
* REQUIRED*/
@property (nonatomic, readwrite) CGPoint position;
@@ -59,9 +59,15 @@ typedef NSInteger JWFoldersOpenDirection;
@property (nonatomic, getter = isTransparentPane) BOOL transparentPane;
+/*
+ Experimental setting that sets the shouldRasterize property
+ on the content view's layer. Defaults to NO.
+ */
+@property (nonatomic, assign) BOOL shouldRasterizeContent;
+
/* The following blocks are called at specific
* times during the lifetime of the folder.
- *
+ *
* The open & close blocks are called immediately before
* the folder is about to open or close, respectively.
*
@@ -88,8 +94,8 @@ typedef NSInteger JWFoldersOpenDirection;
/* Convenience method to open a folder without
* the hassle of setting properties. */
+ (void)openFolderWithContentView:(UIView *)contentView
- position:(CGPoint)position
- containerView:(UIView *)containerView
+ position:(CGPoint)position
+ containerView:(UIView *)containerView
openBlock:(JWFoldersOpenBlock)openBlock
closeBlock:(JWFoldersCloseBlock)closeBlock
completionBlock:(JWFoldersCompletionBlock)completionBlock
View
@@ -1,4 +1,4 @@
-/*
+/*
Copyright (c) 2011, Jonathan Willing
All rights reserved.
Licensed under the BSD License.
@@ -28,9 +28,9 @@ - (JWFolderSplitView *)buttonForRect:(CGRect)aRect
top:(BOOL)isTop
transparent:(BOOL)isTransparent;
- (void)openFolderWithContentView:(UIView *)contentView
- position:(CGPoint)position
- containerView:(UIView *)containerView
- openBlock:(JWFoldersOpenBlock)openBlock
+ position:(CGPoint)position
+ containerView:(UIView *)containerView
+ openBlock:(JWFoldersOpenBlock)openBlock
closeBlock:(JWFoldersCloseBlock)closeBlock
completionBlock:(JWFoldersCompletionBlock)completionBlock
direction:(JWFoldersOpenDirection)direction;
@@ -93,9 +93,9 @@ + (void)openFolderWithContentView:(UIView *)contentView
}
- (void)openFolderWithContentView:(UIView *)contentView
- position:(CGPoint)position
- containerView:(UIView *)containerView
- openBlock:(JWFoldersOpenBlock)openBlock
+ position:(CGPoint)position
+ containerView:(UIView *)containerView
+ openBlock:(JWFoldersOpenBlock)openBlock
closeBlock:(JWFoldersCloseBlock)closeBlock
completionBlock:(JWFoldersCompletionBlock)completionBlock
direction:(JWFoldersOpenDirection)direction {
@@ -106,9 +106,12 @@ - (void)openFolderWithContentView:(UIView *)contentView
self.closeBlock = closeBlock;
self.completionBlock = completionBlock;
self.direction = (direction > 0)?direction:JWFoldersOpenDirectionUp;
-
+
BOOL up = (direction == JWFoldersOpenDirectionUp);
+ contentView.layer.shouldRasterize = self.shouldRasterizeContent;
+ contentView.layer.rasterizationScale = [[UIScreen mainScreen] scale];
+
UIImage *screenshot = [containerView screenshot];
CGFloat width = containerView.frame.size.width;
CGFloat height = containerView.frame.size.height;
@@ -156,7 +159,7 @@ - (void)openFolderWithContentView:(UIView *)contentView
move.fromValue = [NSValue valueWithCGPoint:self.folderPoint];
move.toValue = [NSValue valueWithCGPoint:toPoint];
[up ? self.top.layer : self.bottom.layer addAnimation:move forKey:nil];
-
+
if (openBlock) openBlock(self.contentView, duration, timingFunction);
[(up) ? self.top.layer : self.bottom.layer setPosition:toPoint];
}
@@ -178,7 +181,7 @@ - (void)performClose:(id)sender {
}
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag {
- if ([[anim valueForKey:@"animationType"] isEqualToString:@"close"]) {
+ if ([[anim valueForKey:@"animationType"] isEqualToString:@"close"]) {
[self.top removeFromSuperview];
[self.bottom removeFromSuperview];
[self.contentView removeFromSuperview];
@@ -196,7 +199,7 @@ - (JWFolderSplitView *)buttonForRect:(CGRect)aRect
position:(CGPoint)position
top:(BOOL)isTop
transparent:(BOOL)isTransparent {
- CGFloat scale = [[UIScreen mainScreen] scale];
+ CGFloat scale = [[UIScreen mainScreen] scale];
CGFloat width = aRect.size.width;
CGFloat height = aRect.size.height;
CGPoint origin = aRect.origin;

0 comments on commit 87ec52c

Please sign in to comment.