1

Hi in my application i have a custom view with CALayer (i use it for transition animation), in that view i add some subviews, one of them is a view with NSTableView. Each cell of NSTableView, draws it's content with shadow. Code like this:

NSShadow* shadow = [[NSShadow alloc] init];
[shadow setShadowOffset:NSMakeSize(2.0, -2.0)];
[shadow setShadowBlurRadius:2.0];
[shadow setShadowColor:[[NSColor blackColor] colorWithAlphaComponent:0.3]];
[shadow set];

[self.stringValue drawInRect:NSMakeRect(x, y, w - 60, h) withAttributes:attributes];

When my NSTableView has less than ~50 rows with CALayer turned on OR when i turn off CALayer in IB, i have cells drawn like that: https://i.stack.imgur.com/zMxmK.png

But when my NSTableView has more than ~50 row AND i turn on CALayer in IB, i have cells drawn like that: https://i.stack.imgur.com/IMyIP.png

How can it be? I break my had :(

Vespen
  • 11
  • 2

1 Answers1

1
  • Try changing -2.0 to +2.0 depending on [[NSGraphicsContext currentContext] isFlipped] property.
  • Try changing it depending on whether the view is layered and CALayer has isGeometryFlipped on.
  • If you have flipping transformation(s) applied, note they won't affect NSShadow:

    Shadows are always drawn in the default user coordinate space, regardless of any transformations applied to that space. This means that rotations, translations and other transformations of the current transformation matrix (the CTM) do not affect the resulting shadow. Another way to think about this is that changes to the CTM do not move or change the apparent position of the shadow’s light source.

hamstergene
  • 24,039
  • 5
  • 57
  • 72
  • Thank you for your answer. 1. GraphicsContex is always flipped for me. 2. CALayer geometry is not flipped. 3. I have no transformations applied. It is a strange bug :( – Vespen Jul 21 '12 at 02:37