My implementation may be incorrect but I'm confused as to how to actually use the rect being pushed into CGRect.
I have this code:
I am calling setUpTeams, and what I want it to do is take the first frame at the origin and make it 160 wide and 480 tall (or half of an iPhone screen).
Then it should draw it and the only reason I do the check to see if the rect is starting at the origin is because then I can have the screen split into two different parts.
However, this just seems to draw one big rectangle. Why am I not able to use "rect"?
I have this code:
Code:
-(void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGPoint upperLeft = CGPointMake(0.0,0.0);
CGRect teamFrame = rect;
if(CGRectContainsPoint(teamFrame,upperLeft)) {
CGContextSetRGBFillColor(context, 1.0,0.0,0.0,1.0);
} else {
CGContextSetRGBFillColor(context, 0.0,0.0,1.0,1.0);
}
CGContextFillRect(context, teamFrame);
}
-(void)setUpTeams {
CGRect teamOneFrame = CGRectMake(0,0,160,480);
[self drawRect:teamOneFrame];
CGRect teamTwoFrame = CGRectMake(160,0,160,480);
[self drawRect:teamTwoFrame];
}
I am calling setUpTeams, and what I want it to do is take the first frame at the origin and make it 160 wide and 480 tall (or half of an iPhone screen).
Then it should draw it and the only reason I do the check to see if the rect is starting at the origin is because then I can have the screen split into two different parts.
However, this just seems to draw one big rectangle. Why am I not able to use "rect"?