Posted By

ppaulojr on 12/23/11


Tagged

draw CoreGraphics uiimageview


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Tintenklecks
cnathan


Draw Over UIImageView


 / Published in: Objective C
 

URL: http://www.netfilter.com.br

mainimg is a UIImageView

  1. - (void) drawLine:(CGPoint) pt {
  2.  
  3.  
  4. UIGraphicsBeginImageContext(mainimg.frame.size);
  5. [mainimg.image drawInRect:CGRectMake(0, 0, mainimg.frame.size.width, mainimg.frame.size.height)];
  6.  
  7. CGContextRef ctx = UIGraphicsGetCurrentContext();
  8. CGContextSetLineCap(ctx, kCGLineCapButt);
  9. CGContextSetLineWidth(ctx,2.0);
  10. CGContextSetRGBStrokeColor(ctx, 1.0, 0.0, 0.0, 1.0);
  11. CGContextBeginPath(ctx);
  12. CGContextAddEllipseInRect (ctx,CGRectMake(pt.x-2.0, pt.y-2.0, 4, 4));
  13. CGContextSetFillColorWithColor(ctx, [UIColor redColor].CGColor);
  14. CGContextFillPath(ctx);
  15.  
  16. CGContextStrokePath(ctx);
  17. mainimg.image = UIGraphicsGetImageFromCurrentImageContext();
  18. UIGraphicsEndImageContext();
  19. }

Report this snippet  

You need to login to post a comment.