How to install UIBarButtonItem tintcolor for custom UIColor

I looked through all the typical training topics and questions for tintcolor navigation bars. I have a set of shades for the navigation bar, but I have a mail icon that needs to be changed to its own color when there is mail. (e.g. reddish orange mail icon)

I can adjust the hue correctly only when using system UIColors.

self.leftNavigationBarButton = [[UIBarButtonItem alloc] initWithImage:someImage style:UIBarButtonItemStylePlain target:self action:@selector(foo:)];
self.navigationItem.leftBarButtonItem = self.leftNavigationBarButton;

self.leftNavigationBarButton.tintcolor = [UIColor redColor];

However, if I use custom color.

self.leftNavigationBarButton.tintcolor = [UIColor colorWithRed:100 green:40 blue:20 alpha:1.0];

He makes the icon white. Does anyone know what is happening or how can I use custom color?

+4
source share
1 answer

I figured this out from fooobar.com/questions/68983 / ... answer .

, RGB 255.0.

self.leftNavigationBarButton.tintcolor = [UIColor colorWithRed:100/255.0 green:40/255.0 blue:20/255.0 alpha:1.0];
+1

All Articles