Я работаю над проектом без Interface Builder,
Я хочу нарисовать линию и квадрат теста, но здесь не работает код
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextClearRect(context, rect);
//Set the stroke (pen) color
CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);
//Set the width of the pen mark
CGContextSetLineWidth(context, 5.0);
//Start at this point
//CGContextMoveToPoint(context, 10.0, 30.0);
CGContextMoveToPoint(context, 20, 20);
//Give instructions to the CGContext
//(move "pen" around the screen)
CGContextAddLineToPoint(context, 310.0, 30.0);
CGContextStrokePath(context);
// Draw a red solid square
CGContextSetRGBFillColor(context, 255, 0, 0, 1);
CGContextFillRect(context, CGRectMake(10, 10, 50, 50));
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
self.view.backgroundColor = [UIColor grayColor];
UILabel *labelA = [[[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 20)]autorelease];
labelA.text = @"mk ss9";
[self.view addSubview:labelA];
}
этикетка показывает нормально, но линия и квадрат не показывают, чего не хватает ??
спасибо большое!