Skip to content

Instantly share code, notes, and snippets.

@zapsleep
Created July 29, 2013 10:16
Show Gist options
  • Save zapsleep/6103396 to your computer and use it in GitHub Desktop.
Save zapsleep/6103396 to your computer and use it in GitHub Desktop.
Getter for parallaxView w/o gyro
-(DVParallaxView *)parallaxView {
if (!_parallaxView) {
_parallaxView = [[DVParallaxView alloc] initWithFrame:self.view.bounds];
[_parallaxView setBackgroundImage:[UIImage imageNamed:@"galaxy2"]];
UIImageView *earth = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"earth"]];
earth.frame = (CGRect) {.origin = CGPointMake(CGRectGetMidX(self.view.bounds) - earth.image.size.width/2.f,
CGRectGetMidY(self.view.bounds) - earth.image.size.height/2.f),
.size = earth.frame.size};
[_parallaxView addSubview:earth];
UIImageView *moon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"moon"]];
moon.frame = (CGRect) {.origin = CGPointMake(CGRectGetMidX(self.view.bounds) + 30.f,
CGRectGetMidY(self.view.bounds) + 30.f),
.size = moon.frame.size};
[_parallaxView addSubview:moon];
[_parallaxView setFrontView:self.frontView];
}
return _parallaxView;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment