drawing different quartz 2d
- by Cosizzle
Hello,
I'm trying to make a small application or demo thats a tab bar application. Each bar item loads in a new view. I've created a quartzView class that is called on by the controller:
- (void)viewDidLoad {
quartzView *drawingView = [[quartzView alloc] initWithFrame:CGRectMake(0,0,320,480)];
[self.view addSubview:drawingView];
[super viewDidLoad];
}
From my understanding, the drawRect method must be triggered in order to render the object and to draw it. This is my quartzView class:
#import "quartzView.h"
@implementation quartzView
#pragma mark shapes
// Blue Circle
- (void)drawRect:(CGRect)rect
{
NSLog(@"Trying to draw...");
CGContextRef ctx = UIGraphicsGetCurrentContext(); //get the current context
CGContextClearRect(ctx, rect); //clear off the screen
//draw a red square
CGContextSetRGBFillColor(ctx, 255, 0, 0, 1);
CGContextFillRect(ctx, CGRectMake(10, 10, 50, 50));
}
// ====================================================================================================
#pragma mark -
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
// Initialization code
}
return self;
}
- (void)dealloc {
[super dealloc];
}
@end
So how would I go about to say,
if the view is view one, draw a square
if it's view two draw a circle.
And so on.