Posted By

suibhne on 11/12/09


Tagged

image Objective-c iphone


Versions (?)

Who likes this?

8 people have marked this snippet as a favorite

iswear_wxp
espinallab
avanadra
sb
nsbuckner
wpellis
Tintenklecks
cnathan


Add Image Border to UIImage


 / Published in: Objective C
 

Adds a fine border to a UIImage.

  1. - (UIImage*)imageWithBorderFromImage:(UIImage*)source;
  2. {
  3. CGSize size = [source size];
  4. UIGraphicsBeginImageContext(size);
  5. CGRect rect = CGRectMake(0, 0, size.width, size.height);
  6. [source drawInRect:rect blendMode:kCGBlendModeNormal alpha:1.0];
  7.  
  8. CGContextRef context = UIGraphicsGetCurrentContext();
  9. CGContextSetRGBStrokeColor(context, 1.0, 0.5, 1.0, 1.0);
  10. CGContextStrokeRect(context, rect);
  11. UIImage *testImg = UIGraphicsGetImageFromCurrentImageContext();
  12. UIGraphicsEndImageContext();
  13. return testImg;
  14. }

Report this snippet  

You need to login to post a comment.