Skip to content

Instantly share code, notes, and snippets.

@mattlenz
Created August 20, 2012 23:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattlenz/3409217 to your computer and use it in GitHub Desktop.
Save mattlenz/3409217 to your computer and use it in GitHub Desktop.
Solid-color (stretchable) UIImage generator for RubyMotion
# require 'bubble-wrap'
class UIImage
def self.imageWithColor(color)
if color.is_a?(String)
color = color.to_color
end
rect = CGRectMake(0, 0, 1, 1)
UIGraphicsBeginImageContextWithOptions(rect.size, false, 0)
color.setFill
UIRectFill(rect)
image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
image
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment