Created
October 1, 2012 01:41
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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