Sha256: a92d0a5d111820505e1dfb75d35935a9791e4289872be9faffb6370040f4d44a

Contents?: true

Size: 448 Bytes

Versions: 54

Compression:

Stored size: 448 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

  def cgcolor(alpha=nil)
    uicolor(alpha).CGColor
  end

  def skcolor(alpha=nil)
    uicolor(alpha)
  end

end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
sugarcube-3.0.4 lib/ios/sugarcube-color/nsstring.rb
sugarcube-3.0.3 lib/ios/sugarcube-color/nsstring.rb
sugarcube-3.0.2 lib/ios/sugarcube-color/nsstring.rb
sugarcube-3.0.1 lib/ios/sugarcube-color/nsstring.rb
sugarcube-3.0.0 lib/ios/sugarcube-color/nsstring.rb
sugarcube-2.12.3 lib/ios/sugarcube-color/nsstring.rb
sugarcube-2.12.2 lib/ios/sugarcube-color/nsstring.rb
sugarcube-2.12.1 lib/ios/sugarcube-color/nsstring.rb
sugarcube-2.12.0 lib/ios/sugarcube-color/nsstring.rb
sugarcube-2.11.1 lib/ios/sugarcube-color/nsstring.rb
sugarcube-2.11.0 lib/ios/sugarcube-color/nsstring.rb
sugarcube-2.10.0 lib/ios/sugarcube-color/nsstring.rb
sugarcube-2.9.1 lib/ios/sugarcube-color/nsstring.rb
sugarcube-2.8.2 lib/ios/sugarcube-color/nsstring.rb
sugarcube-2.8.1 lib/ios/sugarcube-color/nsstring.rb
sugarcube-2.8.0 lib/ios/sugarcube-color/nsstring.rb
sugarcube-2.7.1 lib/ios/sugarcube-color/nsstring.rb
sugarcube-2.7.0 lib/ios/sugarcube-color/nsstring.rb
sugarcube-2.6.0 lib/ios/sugarcube-color/nsstring.rb
sugarcube-2.5.0 lib/ios/sugarcube-color/nsstring.rb