Guest User

Untitled

a guest
Aug 14th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. How to draw 2 different colored rectangles in iphone using 2d graphics
  2. - (void)drawRect:(CGRect)rect {
  3.  
  4. CGContextRef context = UIGraphicsGetCurrentContext();
  5. CGContextBeginPath(context);
  6. CGContextSetLineWidth(context, 2.0);
  7. CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);
  8. CGRect rectangle = CGRectMake(60,170,200,80);
  9. CGContextAddRect(context, rectangle);
  10. CGContextStrokePath(context);
  11. CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
  12. CGContextFillRect(context, rectangle);
  13. CGContextClosePath(context);
  14.  
  15. CGContextBeginPath(context);
  16. CGContextSetLineWidth(context, 2.0);
  17. CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);
  18. CGRect rectangle1= CGRectMake(60,170,500,80);
  19. CGContextAddRect(context, rectangle1
  20. );
  21. CGContextStrokePath(context);
  22. CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
  23. CGContextFillRect(context, rectangle);
  24. CGContextClosePath(context);
  25.  
  26. }
Add Comment
Please, Sign In to add comment