2010-03-02 62 views

回答

2

下面的代碼應借鑑像你描述的一個正弦曲線,假設currentBounds是您所在地區吸引內邊框:

CGContextBeginPath(context); 
CGContextMoveToPoint(context, 0.0f, CGRectGetMidY(currentBounds)); 
CGContextAddCurveToPoint(context, currentBounds.size.width/5.0f, CGRectGetMidY(currentBounds) - currentBounds.size.width/5.0f, CGRectGetMidX(currentBounds) - currentBounds.size.width/5.0f, CGRectGetMidY(currentBounds) - currentBounds.size.width/5.0f, CGRectGetMidX(currentBounds), CGRectGetMidY(currentBounds)); 
CGContextAddCurveToPoint(context, CGRectGetMidX(currentBounds) + currentBounds.size.width/5.0f, CGRectGetMidY(currentBounds) + currentBounds.size.width/5.0f, currentBounds.size.width - currentBounds.size.width/5.0f, CGRectGetMidY(currentBounds) + currentBounds.size.width/5.0f, currentBounds.size.width, CGRectGetMidY(currentBounds)); 
CGContextClosePath(context); 
CGContextStrokePath(context); 
2

這是一個Bézier curve?如果你知道其中兩個控制點的位置,使用

CGContextMoveToPoint(context, x, y); 
CGContextAddCurveToPoint(context, ...); // Cubic Bézier curve 

CGContextMoveToPoint(context, x, y); 
CGContextAddQuadCurveToPoint(context, ...); // Quadratic Bézier curve 

插入曲線,然後用

CGContextStrokePath(context); 

中風曲線。

+0

我有種想一些實際的點。我不是最好的夸脫抽屜...... – Jaba 2010-03-02 12:33:15

+4

@Jaba:你甚至沒有提供數字(寬度,高度,3個高亮點的位置),任何人都可以提供實際點數。 – kennytm 2010-03-02 12:59:11