Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you match foreground to background? #560

Closed
devshaww opened this issue Sep 19, 2023 · 1 comment
Closed

How do you match foreground to background? #560

devshaww opened this issue Sep 19, 2023 · 1 comment
Assignees
Labels

Comments

@devshaww
Copy link

What are you trying to achieve with this library exactly? Please describe.
I might get this wrong.

From what I can understand, matching foreground to background is to make 2 images move and scale together so that they look like one image.
But how did you match them?

According to the content of matchForegroundToBackground:
self.backgroundContainerView.superview is exactly scrollview right?
But I think the frame of backgroundContainerView does not change(what changes is the contentOffset)so I don't quiet understand.

Thanks in advance!
That'll be of great help.

@TimOliver
Copy link
Owner

Hi @devshaww! All the code for matching the two is here:

- (void)matchForegroundToBackground
{
if (self.disableForgroundMatching)
return;
//We can't simply match the frames since if the images are rotated, the frame property becomes unusable
self.foregroundImageView.frame = [self.backgroundContainerView.superview
convertRect:self.backgroundContainerView.frame
toView:self.foregroundContainerView];
}

Admittedly, if I was to rebuild this library today, I probably wouldn't do it like that again. It was good for performance in 2015, but it ended up being really messy to handle things like rotations with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants