Skip to content
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
3 changes: 2 additions & 1 deletion Container/MPAnimation.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
@interface MPAnimation : NSObject

+ (UIImage *)renderImageFromView:(UIView *)view;
+ (UIImage *)renderImageFromView:(UIView *)view withRect:(CGRect)frame;

+ (UIImage *)renderImageFromView:(UIView *)view withRect:(CGRect)frame opaque:(BOOL)opaque;
+ (UIImage *)renderImageFromView:(UIView *)view withRect:(CGRect)frame transparentInsets:(UIEdgeInsets)insets;
+ (UIImage *)renderImageForAntialiasing:(UIImage *)image withInsets:(UIEdgeInsets)insets;
+ (UIImage *)renderImageForAntialiasing:(UIImage *)image;
Expand Down
8 changes: 4 additions & 4 deletions Container/MPAnimation.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ @implementation MPAnimation
// Generates an image from the view (view must be opaque)
+ (UIImage *)renderImageFromView:(UIView *)view
{
return [self renderImageFromView:view withRect:view.bounds];
return [self renderImageFromView:view withRect:view.bounds opaque:YES];
}

// Generates an image from the (opaque) view where frame is a rectangle in the view's coordinate space.
// Generates an image from the view where frame is a rectangle in the view's coordinate space.
// Pass in bounds to render the entire view, or another rect to render a subset of the view
+ (UIImage *)renderImageFromView:(UIView *)view withRect:(CGRect)frame
+ (UIImage *)renderImageFromView:(UIView *)view withRect:(CGRect)frame opaque:(BOOL)opaque
{
// Create a new context of the desired size to render the image
UIGraphicsBeginImageContextWithOptions(frame.size, YES, 0);
UIGraphicsBeginImageContextWithOptions(frame.size, opaque, 0);
CGContextRef context = UIGraphicsGetCurrentContext();

// Translate it, to the desired position
Expand Down
7 changes: 7 additions & 0 deletions Container/MPFlipTransition.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
@property (assign, nonatomic) CGFloat coveredPageShadowOpacity;
@property (assign, nonatomic) CGFloat flippingPageShadowOpacity;
@property (strong, nonatomic) UIColor *flipShadowColor;

/**
* Set it to NO to make MPTransition generate layers with non-opaque background.
* Default: YES.
*/
@property (nonatomic, assign) BOOL shouldRenderOpaqueViews;

@property (readonly, nonatomic) MPFlipAnimationStage stage;
@property (assign, nonatomic) CGFloat rubberbandMaximumProgress; // how far up rubberband animation should pull

Expand Down
5 changes: 3 additions & 2 deletions Container/MPFlipTransition.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ - (id)initWithSourceView:(UIView *)sourceView destinationView:(UIView *)destinat
_stage = MPFlipAnimationStage1;
_rubberbandMaximumProgress = DEFAULT_RUBBERBAND_MAX_PROGRESS;
_shouldRenderAllViews = YES;
_shouldRenderOpaqueViews = YES;
}

return self;
Expand Down Expand Up @@ -285,10 +286,10 @@ - (void)buildLayers:(BOOL)isResizing
break;
}

UIImage *pageFacingImage = drawFacing? [MPAnimation renderImageFromView:self.sourceView withRect:forwards? upperRect : lowerRect] : nil;
UIImage *pageFacingImage = drawFacing? [MPAnimation renderImageFromView:self.sourceView withRect:forwards ? upperRect : lowerRect opaque:self.shouldRenderOpaqueViews] : nil;

UIImage *pageBackImage = isRubberbanding? nil : [MPAnimation renderImageFromView:self.destinationView withRect:forwards? destUpperRect : destLowerRect transparentInsets:insets];
UIImage *pageRevealImage = drawReveal? [MPAnimation renderImageFromView:self.destinationView withRect:forwards? destLowerRect : destUpperRect] : nil;
UIImage *pageRevealImage = drawReveal? [MPAnimation renderImageFromView:self.destinationView withRect:forwards ? destLowerRect : destUpperRect opaque:self.shouldRenderOpaqueViews] : nil;

CATransform3D transform = CATransform3DIdentity;

Expand Down