我想画一条线
我的代码是这个
-(void) drawRect:(CGRect) rect
{
NSLog(@"Reached Draw ARect Function");
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(ctx, 2.0);
CGContextSetRGBStrokeColor(ctx, 1.0, 2.0, 0, 1);
CGContextMoveToPoint(ctx, 0, 0);
CGContextAddLineToPoint( ctx, 100,100);
CGContextStrokePath(ctx);
}
我从 viewDidLoad 调用如下
- (void)viewDidLoad {
[super viewDidLoad];
CGRect k = CGRectMake(1.0, 1.0, 100.0, 200.0);
[self.view drawRect:k];
}
任何人都可以帮助我吗?