QMFileCollectionCell.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // QMFileCollectionCell.m
  3. // IMSDK-OC
  4. //
  5. // Created by HCF on 16/8/11.
  6. // Copyright © 2016年 HCF. All rights reserved.
  7. //
  8. #import "QMFileCollectionCell.h"
  9. @interface QMFileCollectionCell () {
  10. UIImageView *_photoImageView;
  11. }
  12. @end
  13. @implementation QMFileCollectionCell
  14. - (instancetype)initWithFrame:(CGRect)frame {
  15. self = [super initWithFrame:frame];
  16. if (self) {
  17. [self createUI];
  18. }
  19. return self;
  20. }
  21. - (void)createUI {
  22. self.contentView.backgroundColor = [UIColor whiteColor];
  23. _photoImageView = [[UIImageView alloc] init];
  24. _photoImageView.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
  25. [self.contentView addSubview:_photoImageView];
  26. self.pickedItemImageView = [[UIImageView alloc] init];
  27. self.pickedItemImageView.frame = CGRectMake(self.bounds.size.width-35, 5, 30, 30);
  28. self.pickedItemImageView.image = [UIImage imageNamed:@"ic_checkbox_pressed"];
  29. [self.contentView addSubview:self.pickedItemImageView];
  30. }
  31. - (void)setImageAsset:(PHAsset *)imageAsset {
  32. if (imageAsset) {
  33. PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
  34. options.synchronous = YES;
  35. options.version = PHImageRequestOptionsVersionCurrent;
  36. options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
  37. options.resizeMode = PHImageRequestOptionsResizeModeExact;
  38. options.networkAccessAllowed = YES;
  39. [self.imageManager requestImageForAsset:imageAsset targetSize:CGSizeMake(120, 120) contentMode:PHImageContentModeAspectFill options:options resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
  40. _photoImageView.image = result;
  41. }];
  42. }
  43. }
  44. @end