Sha256: b2c29b40929a055a0581333b0c70b1b4429e9264c7bd174f8ffca66a30b732eb
Contents?: true
Size: 1.36 KB
Versions: 8
Compression:
Stored size: 1.36 KB
Contents
module SugarCube module Modal module_function def present_modal(view_ctlr, options={}, &block) target = options[:target] || UIApplication.sharedApplication.keyWindow.rootViewController animated = options.fetch(:animated, true) target.presentViewController(view_ctlr, animated:animated, completion:block) end def present_modal_in_nav(view_ctlr, options={}, &block) ctlr = UINavigationController.alloc.initWithRootViewController(view_ctlr) ctlr.modalTransitionStyle = UIModalTransitionStyleCoverVertical SugarCube::Modal.present_modal(ctlr, options, &block) ctlr end def dismiss_modal(options={}, &block) target = options.fetch(:target, UIApplication.sharedApplication.keyWindow.rootViewController) target.dismissViewControllerAnimated(true, completion:block) end end end class UIViewController def present_modal(view_ctlr, options={}, &block) options = options.merge(target: self) SugarCube::Modal.present_modal(view_ctlr, options, &block) end def present_modal_in_nav(view_ctlr, options={}, &block) options = options.merge(target: self) SugarCube::Modal.present_modal_in_nav(view_ctlr, options, &block) end def dismiss_modal(view_ctlr, options={}, &block) options = options.merge(target: self) SugarCube::Modal.dismiss_modal(view_ctlr, options, &block) end end
Version data entries
8 entries across 8 versions & 1 rubygems