Sha256: 382aa254b709b3749cb26360c9ed231b43f6eb83e9644b9a4a8d109401cbfabf

Contents?: true

Size: 676 Bytes

Versions: 6

Compression:

Stored size: 676 Bytes

Contents

#
# The ui-views manipulation functionality
#
module UnderOs::UI::Manipulation

  def insert(view, position=:end)
    if view.is_a?(Array)
      view.each{|v| insert(v, position)}
    else
      if position == :top
        @_.insertSubview(view._, atIndex: 0)
      else
        @_.addSubview(view._)
      end
    end

    self
  end

  def append(*views)
    views.each{|v| insert(v)}
    self
  end

  def prepend(*views)
    views.each{|v| insert(v, :top) }
    self
  end

  def insertTo(view, position=nil)
    view.insert(self, position)
    self
  end

  def remove
    @_.removeFromSuperview
    self
  end

  def clear
    children.each(&:remove)
    self
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
under-os-ui-1.4.0 lib/under_os/ui/utils/manipulation.rb
under-os-1.3.0 lib/under_os/ui/utils/manipulation.rb
under-os-1.2.1 lib/under_os/ui/utils/manipulation.rb
under-os-1.2.0 lib/under_os/ui/utils/manipulation.rb
under-os-1.1.0 lib/under_os/ui/utils/manipulation.rb
under-os-1.0.0 lib/under_os/ui/utils/manipulation.rb