2013-07-24 5 views
-1

안녕하세요, 핵심 애니메이션 및 핵심 graphics.I 작업하고 있어요 사각형 또는 원 또는 타원 않습니다 그래서 그 경로에 프레임을 포기할 수 없습니다 하나의 경로를 그리기. 그라디언트를 설정하려면프레임없이 CAGradientLayer 설정하는 방법

CGPoint point1 = CGPointMake(120.0f, 50.0f); 
CGPoint point2 = CGPointMake(240.0f, 150.0f); 
CGPoint point3 = CGPointMake(360.0f, 50.0f); 
CGPoint point4 = CGPointMake(480.0f+50/2.0, 100.0f); 

CGMutablePathRef curvedPath = CGPathCreateMutable(); 
CGPathMoveToPoint(curvedPath, NULL, 50, 50); 
CGPathAddCurveToPoint(curvedPath, NULL, point1.x, 50, point1.x, 50, point1.x, point1.y); 
CGPathAddCurveToPoint(curvedPath, NULL, point2.x, 50, point2.x, 50, point2.x, point2.y); 
CGPathAddCurveToPoint(curvedPath, NULL, point3.x, 50, point3.x, 50, point3.x, point3.y); 
CGPathAddCurveToPoint(curvedPath, NULL, point4.x, 50, point4.x, 50, point4.x, point4.y); 
CGPathCloseSubpath(curvedPath); 
return curvedPath; 
+0

단순히 위에서 아래 그라데이션을합니다. – user007

답변

1

사용 CGPathGetPathBoundingBox : 색상은 내가 give.Here 내 경로에 대한 코드 캔트 것을, 내가 프레임을 필요로하는 위해 path.But합니다. gradientLayershapeLayer의 계층 또는 마스크 층의 경우,이 시도 :

gradientLayer.frame = CGPathGetPathBoundingBox(shapeLayer.path); 
+0

예 ... 올바른 ... 감사합니다 mannn – user007

+0

내 경우에는 작동하지 않는 시장이 있습니다. –

관련 문제