MJPhoto.m 721 B

12345678910111213141516171819202122232425262728293031
  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 (srcImageView.clipsToBounds) {
  23. _capture = [self capture:srcImageView];
  24. }
  25. }
  26. @end