Letterpress doesn't work with UIColor from a pattern image

281 Views Asked by At

I would like to use a an image as the color of an letter-pressed label but something is not working right and I am not sure what. I create the color with

UIImage *redImage = [UIImage imageNamed:@"Red"];
UIColor *redColor = [UIColor colorWithPatternImage:scaledRedImage];

When I create the attributes

NSDictionary *attributes = @{NSForegroundColorAttributeName : redColor, NSTextEffectAttributeName : NSTextEffectLetterpressStyle}; the label is letter-pressed but the color is white.

When using NSDictionary *attributes = @{NSForegroundColorAttributeName : redColor};, the color is set correctly so I know that the color is created correctly.

NSDictionary *attributes = @{NSForegroundColorAttributeName : [UIColor redColor], NSTextEffectAttributeName : NSTextEffectLetterpressStyle}; works perfectly.

So to sum up:

  1. Letterpress + custom color = white letterpressed text
  2. Letterpress + system color = correctly colored and letterpressed text
  3. Custom color + no letterpress = correctly colored

Why is this happening and how can I fix it?

0

There are 0 best solutions below