I have a UIColor+MyLayout.m file such as:
@implementation UIColor (Layout)
- (UIColor *) textBackground
{
UIColor *lightGreen = [UIColor colorWithRed:0.0f/255.0f green:178.0f/255.0f blue:238.0f/255.0f alpha:1.0f];
return lightGreen;
}
@end
I have added the .h file to my viewcontroller.m, but how do I call this into a UIColor?
UIColor *myColor = ?
You can turn
textBackground
into class method by using+
in signature instead of-
and then simply:Huge screenshot showing coloured text
TRY THIS.... IT IS WORKING!!!!
1. MAke the subclass of
UIColor
named vv.So, in UIColor+vv.h
UIColor+vv.m
ViewController.m
LET me know if you have any problem.
Would be better if you do the following:
And then just call it
UIColor *myColor = [UIColor textBackground];
First you have to import your category file in your class like:
Then you need to call this method as
Also you need to make your category method as a class method
You should make this method static like...
And then just call it using class name like
UIColor *myColor = [UIColor textBackground];
You should import UIColor+MyLayout.h like
#import UIColor+MyLayout.h