NSEdgeInsets capInsets = backgroundImage.capInsets;
NSSize imageSize = backgroundImage.size;
CALayer *layer = someView.layer;
layer.contents = backgroundImage;
layer.contentsScale = self.backingScaleFactor;
if (someView.isFlipped)
{
layer.contentsCenter = CGRectMake(
capInsets.left / imageSize.width,
capInsets.top / imageSize.height,
1.0 - (capInsets.right / imageSize.width),
1.0 - (capInsets.bottom / imageSize.height));
}
else
{
layer.contentsCenter = CGRectMake(
capInsets.left / imageSize.width,
capInsets.bottom / imageSize.height,
1.0 - (capInsets.right / imageSize.width),
1.0 - (capInsets.top / imageSize.height));
}
**** Misuse of NSImage and CALayer. contentsCenter is {{0.037037037037037035, 0.37931034482758619}, {0.96296296296296302, 0.48275862068965514}}. It should be {{0, 0}, {1, 1}}
U wot mate?
Ever found an explanation?