2011-11-14 102 views
1

我想畫的2個pixels..I一行寫了下面的代碼,但它並沒有畫上任何線或任何view..Plzz幫我對此還是告訴我的錯誤在此代碼...在代碼pointToBeShownCGPoint .....廣東話繪製iphone線

- (void)drawRect:(CGRect)rect { 
    // Drawing code.  
CGContextRef context = UIGraphicsGetCurrentContext();  
CGContextSetLineWidth(context, 2.0);  
CGContextSetStrokeColor(context, currentColor.CGColor);   
pointToBeShown.x = 30; 
pointToBeShown.y = 449; 
CGContextMoveToPoint(context, pointToBeShown.x, pointToBeShown.y); 
CGContextAddLineToPoint(context, (pointToBeShown.x + 1),(pointToBeShown.y + 1)); 
CGContextStrokePath(context); 
} 
+0

是您的代碼實際上是被稱爲提到 更新? –

+0

而且你的顏色與背景顏色不同? – TheEye

回答

2

你沒有得到任何警告?

替換行

CGContextSetStrokeColor(context, currentColor.CGColor);   

CGContextSetStrokeColorWithColor(context, currentColor.CGColor);   

更新:如您在評論

CGContextRef context = UIGraphicsGetCurrentContext(); 
[currentColor set]; 
CGContextSetLineWidth(context, 2.0); 
CGContextFillEllipseInRect(context, CGRectMake(pointToBeShown.x, pointToBeShown.y, 10, 10)); 
+0

我假設你的'currenColor'與背景顏色不同,你正在調用這個方法。 – Ilanchezhian

+0

謝謝...它真的有效... – vipul

+0

@vipul:如果你喜歡答案,嘗試接受它作爲答案。 – Ilanchezhian