I want to do something like this, but I cannot get a cooperative syntax.
static const UIColor *colorNavbar = [UIColor colorWithRed: 197.0/255.0 green: 169.0/255.0 blue: 140.0/255.0 alpha: 1.0];
I suppose that I could define macros, but they are ugly.
I like to use categories to extend classes with new methods for this sort of thing. Here’s an excerpt of code I just wrote today:
Now in code I can do things like:
and my own defined colors fit right in alongside the system-defined ones.
(Incidentally, I am starting to think more in terms of HSB than RGB as I pay more attention to colors.)
UPDATE regarding precomputing the value: My hunch is that it’s not worth it. But if you really wanted, you could memoize the values with static variables:
You could make a macro do do the memoizing, too.