lib/ProMotion/screen_helpers/screen_elements.rb in ProMotion-0.5.2 vs lib/ProMotion/screen_helpers/screen_elements.rb in ProMotion-0.6.0

- old
+ new

@@ -1,29 +1,34 @@ module ProMotion module ScreenElements include ProMotion::ViewHelper - - def add(v, attrs = {}) - if attrs && attrs.length > 0 - set_attributes(v, attrs) - end - self.view.addSubview(v) - v + + def add(element, attrs = {}) + add_to self.view, element, attrs end alias :add_element :add alias :add_view :add - def remove(v) - v.removeFromSuperview - v = nil + def remove(element) + element.removeFromSuperview + element = nil end alias :remove_element :remove alias :remove_view :remove + + def add_to(parent_element, element, attrs = {}) + if attrs && attrs.length > 0 + set_attributes(element, attrs) + set_easy_attributes(parent_element, element, attrs) + end + parent_element.addSubview element + element + end def bounds return self.view.bounds end - + def frame return self.view.frame end end