Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Option to use usesDrawViewHierarchyInRect:afterScreenUpdates: #100

Merged
merged 1 commit into from
Jul 20, 2015

Conversation

nscoding
Copy link
Contributor

There have been several cases (#70 #91 #92) where the view needs to be added in a visible UIWindow to display things correctly. Calling fb_imageForLayer: with view.layer is not enough in these cases.

  • The new property (usesDrawViewHierarchyInRect) will use drawViewHierarchyInRect:afterScreenUpdates: like Apple suggests here.
    • The view is added in a UIWindow if needed.
  • Snapshot tests are also improved on the demo application.

@nscoding nscoding changed the title Adding the view in a UIWindow before taking the snapshot Option to use usesDrawViewHierarchyInRect:afterScreenUpdates: Jul 19, 2015
[bluredRedView addSubview:visualEffectView];

self.usesDrawViewHierarchyInRect = YES;
FBSnapshotVerifyView(bluredRedView, nil);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You won't see on snapshot blur/vibrant effect if both view will have same frames.
I would recommend to change to:
UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 40)];
redView.backgroundColor = [UIColor redColor];
visualEffectView.frame = CGRectMake(0, 0, 40, 20);

UIView *parentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
[parentView addSubview:redView];
[parentView addSubview:visualEffectView];

Or something like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@nscoding nscoding force-pushed the nscoding/visualeffects branch 3 times, most recently from c811e7d to 02c6e46 Compare July 20, 2015 02:43
nscoding pushed a commit that referenced this pull request Jul 20, 2015
Option to use usesDrawViewHierarchyInRect:afterScreenUpdates:
@nscoding nscoding merged commit 740e14c into master Jul 20, 2015
@nscoding nscoding deleted the nscoding/visualeffects branch August 10, 2015 00:23
Caiopia pushed a commit to Shopify/ios-snapshot-test-case that referenced this pull request Sep 24, 2019
Previously we would compare UIImage size properties, which are not in pixel units but scale-dependent points. This would cause issues if a test used reference images generated using .none fileNameOptions and ran tests on 2x or 3x simulators: they would fail early because of the size comparison because of the scale difference.

This commit changes the logic to use CGImageGet{Width,Height} instead, which returns the actual pixel size (akin to use size * scale) and is backwards compatible since the image comparison code actually uses CGImage pixel retrieving methods.
Caiopia pushed a commit to Shopify/ios-snapshot-test-case that referenced this pull request Sep 24, 2019
Added PR facebookarchive#100 as the first change that will make it into the next release.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants