2011-02-10 74 views
0

我目前正在起草使用CoreGraphics中對iPhone /石英CGContextAddLineToPoint功能正弦曲線:CoreGraphics中/石英陰影

CGContextRef _context = UIGraphicsGetCurrentContext(); 
CGContextSetLineWidth(_context, 6.0); 
CGColorSpaceRef _colorSpace = CGColorSpaceCreateDeviceRGB(); 
CGFloat _whiteColorComponents[] = {1.0, 1.0, 1.0, 1.0}; 
CGColorRef _color = CGColorCreate(_colorSpace, _whiteColorComponents); 
CGContextSetStrokeColorWithColor(_context, _color); 

CGContextMoveToPoint(_context, 0, 200); 

float _increment = 1; 
for (float _i = 0; _i<320; _i=_i+_increment) { 
    float _sin = ((sin(_i/10) + 1) * 100) + 100; 
    CGContextAddLineToPoint(_context, _i, _sin); 
} 

CGContextStrokePath(_context); 

現在我想添加陰影(而外輝光)到整個路徑。這是可能的使用Quartz(只讀一些關於CGShading,但這似乎有點困難)?

謝謝你在前進, 亞歷山大

回答

0

最簡單的方法將繪製線。

  1. 抽獎 '影子' 線(COLOR1,寬度1)
  2. 在上面繪製法線(顏色2,寬度2)
+0

謝謝您的回答。 有沒有可能讓這條線變模糊,所以看起來更真實? Alexander – alxppp 2011-02-10 11:20:17