. 진정한 "마스크 경로"는 아니지만 인수 레이어의 좌표 공간에서 변형 된 사각형의 경로이며 실제로 필요한 것입니다.
- (NSBezierPath*)layerPathConvertedToLayer:(CALayer*)toLayer
{
CGRect bounds = self.bounds;
CGPoint topLeft = CGPointMake(NSMinX(bounds), NSMinY(bounds));
CGPoint topRight = CGPointMake(NSMaxX(bounds), NSMinY(bounds));
CGPoint bottomRight = CGPointMake(NSMaxX(bounds), NSMaxY(bounds));
CGPoint bottomLeft = CGPointMake(NSMinX(bounds), NSMaxY(bounds));
CGPoint convertedTopLeft = [self convertPoint:topLeft toLayer:toLayer];
CGPoint convertedTopRight = [self convertPoint:topRight toLayer:toLayer];
CGPoint convertedBottomRight = [self convertPoint:bottomRight toLayer:toLayer];
CGPoint convertedBottomLeft = [self convertPoint:bottomLeft toLayer:toLayer];
NSBezierPath *bezierPath = [NSBezierPath bezierPath];
[bezierPath moveToPoint:convertedTopLeft];
[bezierPath lineToPoint:convertedTopRight];
[bezierPath lineToPoint:convertedBottomRight];
[bezierPath lineToPoint:convertedBottomLeft];
[bezierPath lineToPoint:convertedTopLeft];
[bezierPath closePath];
return bezierPath;
}
:
이 방법의 문맥에서의 CALayer 범주이며
출처
2014-03-02 22:04:04
Joe