Sha256: e2aecc262fe9eaffb8bf1900a92ef8a7696c1e3170ba5b4b3bb9e4488a02b1ae

Contents?: true

Size: 338 Bytes

Versions: 29

Compression:

Stored size: 338 Bytes

Contents

class NSString

  # @return [UIColor]
  def uicolor(alpha=nil)
    if self[0,1] == '#'
      if self.length == 4
        return (self[1] * 2 + self[2] * 2 + self[3] * 2).to_i(16).uicolor(alpha)
      end
      return self[1..-1].to_i(16).uicolor(alpha)
    end

    img = UIImage.imageNamed(self)
    img && img.uicolor(alpha)
  end

end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
sugarcube-1.5.9 lib/sugarcube-color/nsstring.rb
sugarcube-1.5.8 lib/sugarcube-color/nsstring.rb
sugarcube-1.5.7 lib/sugarcube-color/nsstring.rb
sugarcube-1.5.6 lib/sugarcube-color/nsstring.rb
sugarcube-1.5.5 lib/sugarcube-color/nsstring.rb
sugarcube-1.5.4 lib/sugarcube-color/nsstring.rb
sugarcube-1.5.3 lib/sugarcube-color/nsstring.rb
sugarcube-1.5.2 lib/sugarcube-color/nsstring.rb
sugarcube-1.5.1 lib/sugarcube-color/nsstring.rb
sugarcube-1.5.0 lib/sugarcube-color/nsstring.rb
sugarcube-1.4.6 lib/sugarcube-color/nsstring.rb
sugarcube-1.4.5 lib/sugarcube-color/nsstring.rb
sugarcube-1.4.4 lib/sugarcube-color/nsstring.rb
sugarcube-1.4.3 lib/sugarcube-color/nsstring.rb
sugarcube-1.4.2 lib/sugarcube-color/nsstring.rb
sugarcube-1.4.1 lib/sugarcube-color/nsstring.rb
sugarcube-1.4.0 lib/sugarcube-color/nsstring.rb
sugarcube-1.3.11 lib/sugarcube-color/nsstring.rb
sugarcube-1.3.10 lib/sugarcube-color/nsstring.rb
sugarcube-1.3.9 lib/sugarcube-color/nsstring.rb