Skip to content

Instantly share code, notes, and snippets.

@jamonholmgren
Created October 1, 2012 01:41
Show Gist options
  • Save jamonholmgren/3808992 to your computer and use it in GitHub Desktop.
Save jamonholmgren/3808992 to your computer and use it in GitHub Desktop.
MBProgressHUD helper (only usable within a UIViewController or something with a self.view accessor)
#
# Usage:
# spinner_on title: "Loading..."
# App.run_after 4 do
# spinner_off
# # more...
# end
#
module SpinnerHelper
def spinner_on(args = {})
hud = MBProgressHUD.showHUDAddedTo(self.view, animated:true)
args.each do |k, v|
hud.send("#{k}=", v) if hud.respond_to? "#{k}="
end
hud.labelText = args[:title] if args[:title] # alias title: for labelText:
hud
end
def spinner_off
hud = MBProgressHUD.hideHUDForView(self.view, animated:true)
hud
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment