我想在我的視圖中繪製這個畫線,我有我需要做的一切基本線的一切,但我不擅長繪圖,事實上我試圖做到這一點,但只是無法讓它正常工作。 alt text http://www.freeimagehosting.net/uploads/50b06b1701.jpg我如何使用CGContext繪製這個圖像
0
A
回答
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);
中風曲線。
相關問題
- 1. iOS - 用CGContext和變換繪製圖像
- 2. 如何使用cgcontext iOS繪製虛線?
- 3. 使用CGContext繪製線條
- 4. 使用CGContext的繪圖圈
- 5. 使用CGContext時的圖像繪製問題。圖像水平鏡像
- 6. CGContext - 「模」繪圖?
- 7. 在iOS中使用TouchesMoved繪製CGContext Line
- 8. 如何在CGContext CGMutablePathRef上繪製頂點?
- 9. 使用CGContext繪圖後擦除
- 10. 如何使用GCD繪製圖像?
- 11. iPhone - 使用CGContext繪製一些文字:確定但是...鏡像
- 12. 如何使用CGContext在現有的UIView上繪製?
- 13. 我如何在Core Graphics中繪製這樣的圖像
- 14. Java:我如何更快地繪製這些圖像?
- 15. Android:我如何繪製這個LinearLayout?
- 16. 如何在R中繪製這個圖?
- 17. 使用CGImage繪製圖像?
- 18. 如何保存我在CGContext中繪製的內容
- 19. 使用paintComponent()繪製多個圖像
- 20. 如何繪製多個CCSprite對象使用一個圖像?
- 21. 如何繪製swt圖像?
- 22. Matlab。如何繪製圖像
- 23. 如何繪製圖像
- 24. 如何在圖像縮放時使用手指繪製圖像?
- 25. 如何使用Python 2.7繪製這個領結圖案?
- 26. 用CGContext繪製三角形/箭頭線
- 27. 如何在繪製多個UIImage時優化CGContext內存消耗?
- 28. 如何使用SurfaceView繪製單個複雜圖像
- 29. Scala:我如何成功繪製這個條形圖?
- 30. 如何用PDFsharp繪製圓形圖像
我有種想一些實際的點。我不是最好的夸脫抽屜...... – Jaba 2010-03-02 12:33:15
@Jaba:你甚至沒有提供數字(寬度,高度,3個高亮點的位置),任何人都可以提供實際點數。 – kennytm 2010-03-02 12:59:11