Where should I store 30+ UIColors for quick reference?

后端 未结 2 1260
忘了有多久
忘了有多久 2021-01-17 01:01

I want to have 30+ constant UIColors so I can easily access them in my app. I\'d like to be able to do something like this:

 [self setBackgroundColor:[UICol         


        
2条回答
  •  感动是毒
    2021-01-17 02:01

    You can add lines like this:

    #define kFirstColor [UIColor whiteColor]
    #define kSecondColor [UIColor colorWithRed:100.0/255 green:100.0/255 blue:100.0/255 alpha:1.0]
    

    At the beginning of a class or add a Color.h header to your project and import it when needed.

    #import "Color.h"
    

    Then you can use your custom colors this way:

    self.view.backgroundColor = kSecondColor;
    

提交回复
热议问题