Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set global variable with UIColor class

i am developing on iPhone application. in this app i have 4 different views. in all views i set background color. see bellow code

self.view.backgroundColor = [UIColor colorWithRed:(238.0f/255.0f) green:(251.0f/255.0f) blue:(255.0f/255.0f) alpha:0.8f];

i am testing various colors for background color. when i have to change any colour i need to change in all view controllers. instead of that can i make global variable for this ? i don't know how to set UIColor in global variable. please suggest me some ideas.

like image 327
Bhavin_m Avatar asked Jan 14 '23 23:01

Bhavin_m


1 Answers

Very simple.
In AppDelegate.h:

#define kGlobalColor [UIColor colorWithRed:(238.0f/255.0f) green:(251.0f/255.0f) blue:(255.0f/255.0f) alpha:0.8f]

In ViewControllers:

#import "AppDelegate.h"

self.view.backgroundColor = kGlobalColor;
like image 198
pbibergal Avatar answered Jan 25 '23 16:01

pbibergal