Skip to content

Instantly share code, notes, and snippets.

@winder
Created March 29, 2010 02:45
Show Gist options
  • Save winder/347303 to your computer and use it in GitHub Desktop.
Save winder/347303 to your computer and use it in GitHub Desktop.
- (void)startSplash {
[[[[UIApplication sharedApplication] windows] objectAtIndex:0] addSubview:self];
splashImage = [[UIImageView alloc] initWithImage:self.image];
if (self.animationIn == SplashViewAnimationNone)
{
[self addSubview:splashImage];
}
else if (self.animationIn == SplashViewAnimationFade)
{
// add the splash image
[self addSubview:splashImage];
// set up a transition animation
CATransition *anim = [CATransition animation];
[anim setDuration:self.animationDelay];
[anim setType:kCATransitionPush];
[anim setSubtype:kCATransitionFade];
[anim setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[self layer] addAnimation:anim forKey:@"fade in"];
}
// Slide in
else
{
// add the splash image
[self addSubview:splashImage];
// set up a transition animation
CATransition *anim = [CATransition animation];
[anim setDuration:self.animationDelay];
[anim setType:kCATransitionPush];
NSString *transitionType;
switch (self.animationIn)
{
case (SplashViewAnimationSlideLeft):
transitionType = kCATransitionFromLeft;
break;
case (SplashViewAnimationSlideRight):
transitionType = kCATransitionFromRight;
break;
case (SplashViewAnimationSlideUp):
transitionType = kCATransitionFromTop;
break;
case (SplashViewAnimationSlideDown):
transitionType = kCATransitionFromBottom;
break;
}
[anim setSubtype:transitionType];
[anim setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[self layer] addAnimation:anim forKey:@"SwitchToView1"];
}
// Dismiss after delay.
[self performSelector:@selector(dismissSplash) withObject:self afterDelay:self.delay];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment