Closed brototyp closed 6 years ago
Let me know if you accept pull requests for this. I will happily implement this.
Since this is "just" an extension of a UIImage I wouldn't do any caching. If someone is using this heavily, they should also do the caching in my opinion.
What about extending the function to allow different sizes of colored Images?
static function with(_ color: UIColor, size: CGSize = CGSize(1,1)) -> UIImage
But in general I'm fine with that piece of byte :)
@achelsmar Thanks for your feedback.
About the caching. I just added a very simple one but I am open to discussions about that one.
About different sizes: What would be the point in doing that? In the end there is no information added, right? If you want to display a 2x2 square (or what ever size) in the same color one can simply stretch the 1x1 image, right? Or did I miss a point that you had in mind?
From time to time it is helpful to generate a 1x1 sized image with just one color. For example if one wants to set the background color of a UIButton in the highlighted state.
Thus I propose the following function.
Things open for discussion: Should we add any caching?