class UnderOs::UI::Image

Public Class Methods

new(options) click to toggle source
Calls superclass method UnderOs::UI::View::new
# File lib/under_os/ui/image.rb, line 4
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

Public Instance Methods

load(url, options={}, &complete) click to toggle source
# File lib/under_os/ui/image.rb, line 24
def load(url, options={}, &complete)
  UnderOs::HTTP.get(url, options) do |response|
    self.src = response.data
    complete.call(response) if complete && complete.arity != 0
    complete.call           if complete && complete.arity == 0
  end
end
src() click to toggle source
# File lib/under_os/ui/image.rb, line 14
def src
  @_.image
end
src=(src) click to toggle source
# File lib/under_os/ui/image.rb, line 18
def src=(src)
  src = UIImage.imageNamed(src)    if src.is_a?(String)
  src = UIImage.imageWithData(src) if src.is_a?(NSData)
  @_.image = src
end