Sha256: de344ad0e6592bc28b1684cbfa73b2978e3c96c147437d29a36404a7eb25c1f2

Contents?: true

Size: 722 Bytes

Versions: 3

Compression:

Stored size: 722 Bytes

Contents

class UnderOs::UI::Image < UnderOs::UI::View
  wraps UIImageView, tag: 'img'

  def initialize(options)
    options = {srs: options} unless options.is_a?(Hash)

    super(options)

    @_.contentMode = UIViewContentModeScaleAspectFit

    self.src = options.delete(:src) if options.has_key?(:src)
  end

  def src
    @_.image
  end

  def src=(src)
    src = UIImage.imageNamed(src) if src.is_a?(String)
    @_.image = src
  end

  def load(url, options={}, &complete)
    UnderOs::HTTP.get(url, options) do |response|
      self.src = UIImage.imageWithData(response.data)
      complete.call(response) if complete && complete.arity != 0
      complete.call           if complete && complete.arity == 0
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
under-os-1.2.0 lib/under_os/ui/image.rb
under-os-1.1.0 lib/under_os/ui/image.rb
under-os-1.0.0 lib/under_os/ui/image.rb