In my main view I have a user-defined class drawSquare that is a subclass of UIImageView. In drawSquare.m I have the normal drawRect method shown below:
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context,[UIColor redColor].CGColor);
redSquare = CGRectMake(2,2,30,34);
CGContextAddRect(context, redSquare);
CGContextStrokePath(context);
}
In my main view controller I have an object named word1Area of type drawSquare as an IBOutlet. In my viewDidLoad method of my main view controller I have the lines:
[self.view addSubview:word1Area];
[word1Area drawRect:word1Area.frame];
I get an "invalid context" run time error. I have tried other variations of calling the drawRect method but keep getting the same error. Thanks for any help.