Skip to content

Instantly share code, notes, and snippets.

@GantMan
Created August 26, 2013 03:03
Show Gist options
  • Save GantMan/6337790 to your computer and use it in GitHub Desktop.
Save GantMan/6337790 to your computer and use it in GitHub Desktop.
Suggested code for fade-in of splash.
def open_screen(screen, args={})
screen = screen.new if screen.respond_to?(:new)
self.home_screen = screen
self.window ||= self.ui_window.alloc.initWithFrame(UIScreen.mainScreen.bounds)
self.window.rootViewController = (screen.navigationController || screen)
splash_fade = args.respond_to?(:splash_fade)
if splash_fade
image = (568 == UIScreen.mainScreen.bounds.size.height) ? ("Default-568h") : ("Default")
image_view = UIImageView.alloc.initWithImage(UIImage.imageNamed(image))
@window.rootViewController.view.addSubview(image_view)
@window.rootViewController.view.bringSubviewToFront(image_view)
end
self.window.makeKeyAndVisible
if splash_fade
# fade out splash image
UIView.transitionWithView(@window, duration:splash_fade, options:UIViewAnimationOptionTransitionNone, animations: lambda {image_view.alpha = 0}, completion: lambda do |finished|
image_view.removeFromSuperview
image_view = nil
end)
end
screen
end
alias :open :open_screen
alias :open_root_screen :open_screen
alias :home :open_screen
@jamonholmgren
Copy link

Looks pretty good! I'll make an issue.

EDIT: Looks like you already did: jamonholmgren/ProMotion#281

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment