Add Image Border to UIImage


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

Adds a fine border to a UIImage.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.