Sha256: 45ee802226220ed3700c524343dbc882f231f9ebd8aa52b6247f4dcc12f5ce35
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
=begin { url: "http://mysite.com/pic.jpg" } =end module Walt class ImageAsset < Asset PROPERTIES = [:url] attr_accessor *PROPERTIES def initialize(params = {}) super params.is_a?(NSDictionary) && params.each do |key, value| if PROPERTIES.include?(key.to_sym) self.send("#{key}=", value) end end end def view if !@view @view = UIImageView.alloc.initWithFrame(CGRectZero) @view.frame = [self.position || CGPointZero, self.size || CGSizeZero] @view.contentMode = self.view_content_mode @view.clipsToBounds = self.clips_to_bounds url = NSURL.URLWithString(self.url) @view.setImageWithURLRequest(NSURLRequest.requestWithURL(url), placeholderImage:nil, success: lambda {|request, response, image| @view.image = image if !self.size @view.sizeToFit end Dispatch::Queue.main.async do self.on_ready(true) end }, failure: lambda {|request, response, error| }) @view end @view end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
walt-0.1 | lib/walt/asset/image.rb |