lib/ProMotion/screen/screen_module.rb in ProMotion-2.1.0 vs lib/ProMotion/screen/screen_module.rb in ProMotion-2.2.0

- old
+ new

@@ -31,10 +31,31 @@ else PM.logger.warn("title expects string, UIView, or UIImage, but #{self.class.title.class.to_s} given.") end end + def resolve_status_bar + case self.class.status_bar_type + when :none + status_bar_hidden true + when :light + status_bar_hidden false + status_bar_style UIStatusBarStyleLightContent + else + status_bar_hidden false + status_bar_style UIStatusBarStyleDefault + end + end + + def status_bar_hidden(hidden) + UIApplication.sharedApplication.setStatusBarHidden(hidden, withAnimation:self.class.status_bar_animation) + end + + def status_bar_style(style) + UIApplication.sharedApplication.setStatusBarStyle(style) + end + def parent_screen=(parent) @parent_screen = WeakRef.new(parent) end def first_screen? @@ -44,10 +65,11 @@ def view_did_load self.send(:on_load) if self.respond_to?(:on_load) end def view_will_appear(animated) + resolve_status_bar self.will_appear self.will_present if isMovingToParentViewController end def will_appear; end @@ -188,9 +210,25 @@ end def title_view(t) @title = t @title_type = :view + end + + def status_bar(style=nil, args={}) + if NSBundle.mainBundle.objectForInfoDictionaryKey('UIViewControllerBasedStatusBarAppearance').nil? + PM.logger.warn("status_bar will have no effect unless you set 'UIViewControllerBasedStatusBarAppearance' to false in your info.plist") + end + @status_bar_style = style + @status_bar_animation = args[:animation] if args[:animation] + end + + def status_bar_type + @status_bar_style || :default + end + + def status_bar_animation + @status_bar_animation || UIStatusBarAnimationSlide end end def self.included(base) base.extend(ClassMethods)