- (void)drawRect:(CGRect)rect
{
CGFloat red[4] = {1.0f, 0.0f, 0.0f, 1.0f};
CGContextSetStrokeColor(c, red);
CGContextBeginPath(c);
CGContextMoveToPoint(c, 150.0f, 200.0f);
CGContextSetLineWidth(c, 5.0f);
CGContextAddLineToPoint(c, 50,300);
CGContextAddLineToPoint(c, 260,300);
CGContextClosePath(c);
}
這裏是我的viewwillappear
的iOS無法畫出簡單的線條
-(void)viewWillAppear:(BOOL)animated
{
[self.view setNeedsDisplay];
}
然而,鑑於無法劃清界線,只是白色的空白。
你的代碼沒有意義。什麼是'c'?如果這是你的真實代碼,編譯器會抱怨。無論如何,或者你正在以一種無意義的方式將'c'設置成一個伊娃。您只能從'drawRect'中獲取繪圖上下文,並且您的代碼沒有這樣做。所以問題不在於iOS無法繪製;這就是*你*不知道如何畫畫。我的書教你:http://www.apeth.com/iOSBook/ch15.html – matt
c = uigraphicgetccurrentcontext –
但這不在你的代碼中。那麼你的代碼只是一個謊言? – matt