MJPhoto.m 812 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // MJPhoto.m
  3. //
  4. // Created by mj on 13-3-4.
  5. // Copyright (c) 2013年 itcast. All rights reserved.
  6. #import <QuartzCore/QuartzCore.h>
  7. #import "MJPhoto.h"
  8. @implementation MJPhoto
  9. #pragma mark 截图
  10. - (UIImage *)capture:(UIView *)view
  11. {
  12. UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0.0);
  13. [view.layer renderInContext:UIGraphicsGetCurrentContext()];
  14. UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
  15. UIGraphicsEndImageContext();
  16. return img;
  17. }
  18. - (void)setSrcImageView:(UIImageView *)srcImageView
  19. {
  20. _srcImageView = srcImageView;
  21. _placeholder = srcImageView.image;
  22. if ( _placeholder == nil ) self.placeholder = [UIImage imageNamed:@"loading170"];
  23. if (srcImageView.clipsToBounds) {
  24. _capture = [self capture:srcImageView];
  25. }
  26. }
  27. @end