Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to draw 2 different colored rectangles in iphone using 2d graphics
- - (void)drawRect:(CGRect)rect {
- CGContextRef context = UIGraphicsGetCurrentContext();
- CGContextBeginPath(context);
- CGContextSetLineWidth(context, 2.0);
- CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);
- CGRect rectangle = CGRectMake(60,170,200,80);
- CGContextAddRect(context, rectangle);
- CGContextStrokePath(context);
- CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
- CGContextFillRect(context, rectangle);
- CGContextClosePath(context);
- CGContextBeginPath(context);
- CGContextSetLineWidth(context, 2.0);
- CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);
- CGRect rectangle1= CGRectMake(60,170,500,80);
- CGContextAddRect(context, rectangle1
- );
- CGContextStrokePath(context);
- CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
- CGContextFillRect(context, rectangle);
- CGContextClosePath(context);
- }
Add Comment
Please, Sign In to add comment