Sha256: 36f9ffefc8657c37afbfe10fc8c8dd2576568a8180e7e3524af73407ac68d989

Contents?: true

Size: 326 Bytes

Versions: 9

Compression:

Stored size: 326 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 = self.uiimage
    img && img.uicolor(alpha)
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sugarcube-1.1.0 lib/sugarcube-color/nsstring.rb
sugarcube-1.0.7 lib/sugarcube-color/nsstring.rb
sugarcube-1.0.6 lib/sugarcube-color/nsstring.rb
sugarcube-1.0.5 lib/sugarcube-color/nsstring.rb
sugarcube-1.0.4 lib/sugarcube-color/nsstring.rb
sugarcube-1.0.3 lib/sugarcube-color/nsstring.rb
sugarcube-1.0.2 lib/sugarcube-color/nsstring.rb
sugarcube-1.0.1 lib/sugarcube-color/nsstring.rb
sugarcube-1.0.0 lib/sugarcube-color/nsstring.rb