Draw rectangle with blue border and fill the rectangular space with red


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  1. - (void)drawRect:(CGRect)rect {
  2.  
  3. CGContextRef context = UIGraphicsGetCurrentContext();
  4.  
  5. CGContextSetLineWidth(context, 2.0);
  6. CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);
  7. CGRect rectangle = CGRectMake(60,170,200,80);
  8. CGContextAddRect(context, rectangle);
  9. CGContextStrokePath(context);
  10. CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
  11. CGContextFillRect(context, rectangle);
  12. }

URL: http://www.techotopia.com/index.php/An_iPhone_Graphics_Drawing_Tutorial_using_Quartz_2D#Drawing_a_Rectangle

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.