2011-03-28 30 views
1

任何人都可以給我簡單的代碼,在iphone中使用drawrect創建一條線嗎?Iphone圖形

+0

看到這個問題:http://stackoverflow.com/問題/ 856354 /如何在iPhone上繪製線條 – 2011-03-28 06:08:19

回答

0

經過博客教程繪製形狀,包括線

http://howtomakeiphoneapps.com/2009/08/how-to-draw-shapes-with-core-graphics/

編輯:下面是繪製行代碼

- (void)drawRect:(CGRect)rect { 
    CGContextRef c = UIGraphicsGetCurrentContext(); 

    CGFloat red[4] = {1.0f, 0.0f, 0.0f, 1.0f}; 
    CGContextSetStrokeColor(c, red); 
    CGContextBeginPath(c); 
    CGContextMoveToPoint(c, 5.0f, 5.0f); 
    CGContextAddLineToPoint(c, 50.0f, 50.0f); 
    CGContextStrokePath(c); 
} 
+0

@Jayaraj:接受我的答案,如果它可以幫助你.. – Jhaliya 2011-03-29 03:30:54