Chisx
Chisx

Reputation: 1986

How do I write custom color coding?

I'm using this code in my viewDidLoad method for my UserCreationViewController

NSDictionary *textAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                [UIColor greenColor],NSForegroundColorAttributeName,
                                [UIColor blackColor],NSBackgroundColorAttributeName,nil];

self.navigationController.navigationBar.titleTextAttributes = textAttributes;
self.title = @"User Creation";

What I want to know is, and I understand that I can change the UIColor to redColor, yellowColor(etc.), is how can I code my custom "color well" color.

In other words How can I set the color if this navigationBar title to a custom color picked from the color well?

Upvotes: 0

Views: 79

Answers (1)

Ilya Dmitriev
Ilya Dmitriev

Reputation: 1730

You can use following code:

UIColor *customColor = [UIColor colorWithRed:155.0/255.0 green:10.0/255.0 blue:50.0/255.0 alpha:1.0];

or

UIColor *customColor = [UIColor colorWithHue: 0.667 saturation: 1.0 brightness: 1.0 alpha: 1.0];

More info.

Upvotes: 1

Related Questions