Your Ad Here

Posted By

arpit on 10/29/10


Tagged

drawingAPI CGContext


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite



Bordered Image


 / Published in: Objective C
 

URL: http://www.drobnik.com/touch/2010/07/drawing-on-uiimages/

Draws a border on an Image Object. Based on the link mentioned above.

  1. - (UIImage *)imageByDrawingBorderOnImage:(UIImage *)image
  2. {
  3. UIGraphicsBeginImageContext(image.size);
  4. [image drawAtPoint:CGPointZero];
  5.  
  6. CGContextRef ctx = UIGraphicsGetCurrentContext();
  7. CGContextSetLineWidth(ctx, 10);
  8. CGContextSetRGBStrokeColor(ctx, 1.000,0.902,0.118, 1.000);
  9.  
  10. CGRect borderRect = CGRectMake(0, 0,
  11. image.size.width,
  12. image.size.height);
  13.  
  14. CGContextStrokeRect(ctx, borderRect);
  15.  
  16. UIImage *retImage = UIGraphicsGetImageFromCurrentImageContext();
  17. UIGraphicsEndImageContext();
  18.  
  19. return retImage;
  20. }

Report this snippet  

You need to login to post a comment.