ImageSelectorCollectionCell.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // ImageSelectorCollectionCell.m
  3. // shiku_im
  4. //
  5. // Created by 1 on 17/1/20.
  6. // Copyright © 2017年 Reese. All rights reserved.
  7. //
  8. #import "ImageSelectorCollectionCell.h"
  9. @interface ImageSelectorCollectionCell()
  10. @property (nonatomic,assign) NSInteger cellIndex;
  11. @end
  12. @implementation ImageSelectorCollectionCell
  13. -(instancetype)initWithFrame:(CGRect)frame{
  14. self = [super initWithFrame:frame];
  15. if (self) {
  16. [self customViewWithFrame:frame];
  17. }
  18. return self;
  19. }
  20. - (void)customViewWithFrame:(CGRect)frame{
  21. _imageView = [[JXImageView alloc] init];
  22. _imageView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
  23. _imageView.contentMode = UIViewContentModeScaleAspectFit;
  24. [self.contentView addSubview:_imageView];
  25. // [_imageView release];
  26. _selectView = [[JXImageView alloc] init];
  27. _selectView.frame = CGRectMake(frame.size.width-33-5, 5, 33, 33);
  28. _selectView.backgroundColor = [UIColor clearColor];
  29. [self.contentView addSubview:_selectView];
  30. // [_selectView release];
  31. }
  32. -(void)refreshCellWithImagePath:(NSString *)imagePath{
  33. _yellow.didTouch = self.didImageView;
  34. _imageView.didTouch = self.didImageView;
  35. _selectView.didTouch = self.didSelectView;
  36. _imageView.image = [UIImage imageWithContentsOfFile:imagePath];
  37. if (!_imageView.image) {
  38. [_imageView sd_setImageWithURL:[NSURL URLWithString:imagePath] placeholderImage:[UIImage imageNamed:@"Default_Gray"]];
  39. }
  40. }
  41. -(void)dealloc{
  42. // [super dealloc];
  43. }
  44. -(void)setIsSelected:(BOOL)value{
  45. if (value){
  46. _imageView.layer.borderWidth = 3;
  47. _imageView.layer.borderColor = [[UIColor yellowColor] CGColor];
  48. _selectView.image = [UIImage imageNamed:@"selected_true"];
  49. }
  50. else{
  51. _imageView.layer.borderWidth = 0;
  52. _selectView.image = [UIImage imageNamed:@"selected_fause"];
  53. }
  54. }
  55. -(void)setDelegate:(id)value{
  56. _delegate = value;
  57. _selectView.delegate = _delegate;
  58. _imageView.delegate = _delegate;
  59. _yellow.delegate = _delegate;
  60. }
  61. -(void)setIndex:(long)value{
  62. _index = value;
  63. _selectView.tag = _index;
  64. _imageView.tag = _index;
  65. _yellow.tag = _index;
  66. }
  67. @end