RubyMotion wrapper for MBProgressHud
DRY up your MBProgressHUD in RubyMotion
Usage:
HUD.wrap(@myView, proc do
sleep 20
end, proc do
App.alert("Done loading!")
end)
Dependencies:
- MBProgressHUD (duh)
- BubbleWrap::Reactor
Installation:
1. Create a file in lib
called hud.rb
2. Add app.files.unshift(*Dir['lib/*.rb'])
to your Rakefile
class HUD
def self.wrap(view, operation, callback)
MBProgressHUD.showHUDAddedTo(view, animated:true)
BW::Reactor.defer(operation, proc do
MBProgressHUD.hideHUDForView(view, animated:true)
callback.call
end)
end
end
Written by Alan deLevie
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#