Reputation: 7484
Trying to change the color of a shadow. This works:
self.layer.shadowColor = [[UIColor blueColor] CGColor];
but i want to make it a custom color, so i tried:
self.layer.shadowColor = [[UIColor colorWithRed:191/255.0f green:199/255.0f blue:203/255.0f alpha:1] CGColor];
which does not work.
what am i doing wrong?
EDIT:
code snippet from my init method:
self.layer.shadowOpacity = 0;
self.layer.shadowColor = [[UIColor blueColor] CGColor];
//self.layer.shadowColor = [[UIColor colorWithRed:191/255.0f green:199/255.0f blue:203/255.0f alpha:1] CGColor];
self.layer.shadowOffset = CGSizeMake(0,0);
self.layer.shadowRadius = 4;
EDIT 2:
odd part is that i extended UIColor to include some of my custom colors; if i use:
self.layer.shadowColor = [[UIColor pointColorBlue] CGColor];
from my UIColor+myColor:
+(UIColor *) pointColorBlue
{
return [UIColor colorWithRed:50/255.0f green:50/255.0f blue:255/255.0f alpha:1];
}
it works fine.
Upvotes: 0
Views: 2401
Reputation: 7484
Bah! figured it out: the graphics guy gave me that RGB value which is nearly identical to the background color!
Upvotes: 1
Reputation: 6852
Those should work.
But you have to do following:
CALayer newLayer = [CALayer layer];
newLayer.shadowColor = [[UIColor blueColor] CGColor];
self.layer = newLayer;
[self.layer setWantsLayer:YES];
It's important to reset the main layer, cause otherways it does not get drawn.
Upvotes: 0