Given #f7dd37
, this workflow will generate a line like this [UIColor colorWithRed:247.0 / 255.0 green:221.0 / 255.0 blue:55.0 / 255.0 alpha:1.0]
and paste it into the frontmost application. http://cl.ly/SD9L
Last active
December 26, 2015 22:09
-
-
Save kmikael/7221495 to your computer and use it in GitHub Desktop.
Generate a UIColor constructor from a given hex string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
red, green, blue = '{query}'.match(/#?(..)(..)(..)/).to_a.drop(1).map(&:hex).map(&:to_f) | |
print "[UIColor colorWithRed:#{red} / 255.0 green:#{green} / 255.0 blue:#{blue} / 255.0 alpha:1.0]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment