0

I'm trying to add a nice looking shadow to a NSTextViews string, I have this Code so far:

NSShadow *textShadow = [[NSShadow alloc] init];
textShadow.shadowColor = [[NSColor blackColor]
                              colorWithAlphaComponent:0.3];
textShadow.shadowOffset = NSMakeSize(5.0, -5.0);
textShadow.shadowBlurRadius = 3;

NSDictionary *d = @{NSShadowAttributeName : textShadow,
                          NSFontAttributeName : [NSFont fontWithName:@"Arial Black" size:36.0],
                   NSStrokeWidthAttributeName : [NSNumber numberWithFloat:-3.0],
                   NSStrokeColorAttributeName : [NSColor whiteColor]};
[tv setTypingAttributes:d];

all in all this brings up a pretty looking Drop shadow on the right and the bottom of the string in the NSTextView but because the internal drawing mechanism of the textview seems to draw the "fill" of the Characters first and then the stroke around it, the Shadow lays above the fill of the text in the upper left of the Chars, which looks very bad as you can see here(would post an Image but not enough reputation right now 8-/ )

Is there a better way to add the shadow or a way to "raise" the fill color of the String so it lays above the shadow or is this kind of a Bug in the Foundation framework?

Thanks and greetings, Alex.

Ramy Al Zuhouri
  • 21,580
  • 26
  • 105
  • 187
miradorn
  • 75
  • 6
  • So where's the shadow? I just see an orange circle. – Ramy Al Zuhouri Jan 09 '13 at 21:20
  • The green Text with "Test" as a string, the orange dot is not relevant. You can see the wrong shadow very good at the inner side on the top left of the "T" – miradorn Jan 09 '13 at 21:21
  • Maybe the attributed string "Test" has a too low alpha channel. – Ramy Al Zuhouri Jan 10 '13 at 00:07
  • Where is the code for your fill color? A shadow will show through a non-opaque fill. – uchuugaka Jan 10 '13 at 05:01
  • The String ist automatically filled and stroked through `NSStrokeWidthAttributeName : [NSNumber numberWithFloat:-3.0],`and the Color can be chosen by the User through a Color picker with variable alpha channel, so what i need is a shadow that is drawn "behind" the fill. – miradorn Jan 10 '13 at 09:21

0 Answers0