AJPhotoGroupCell.m 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // AJPhotoGroupCell.m
  3. // AJPhotoPicker
  4. //
  5. // Created by AlienJunX on 15/11/2.
  6. // Copyright (c) 2015 AlienJunX
  7. //
  8. // This source code is licensed under the MIT-style license found in the
  9. // LICENSE file in the root directory of this source tree.
  10. //
  11. #import "AJPhotoGroupCell.h"
  12. @interface AJPhotoGroupCell()
  13. @property (nonatomic, strong) UIImageView *groupImageView;
  14. @property (nonatomic, strong) UILabel *groupTextLabel;
  15. @end
  16. @implementation AJPhotoGroupCell
  17. - (void)bindModel:(TZAlbumModel *)model{
  18. // self.assetsGroup = assetsGroup;
  19. self.backgroundColor = [UIColor whiteColor];
  20. if (self.groupImageView == nil) {
  21. UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(14, 5, 50, 50)];
  22. imageView.contentMode = UIViewContentModeScaleAspectFill;
  23. imageView.layer.masksToBounds = YES;
  24. //imageView.backgroundColor = [UIColor greenColor];
  25. [self.contentView addSubview:imageView];
  26. self.groupImageView = imageView;
  27. }
  28. if (self.groupTextLabel == nil) {
  29. UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(70, 5, [UIScreen mainScreen].bounds.size.width-70, 50)];
  30. textLabel.font = [UIFont boldSystemFontOfSize:16];
  31. textLabel.backgroundColor = [UIColor clearColor];
  32. textLabel.numberOfLines = 0;
  33. textLabel.textColor = [UIColor blackColor];
  34. [self.contentView addSubview:textLabel];
  35. self.groupTextLabel = textLabel;
  36. }
  37. [[TZImageManager manager] getPostImageWithAlbumModel:model completion:^(UIImage *postImage) {
  38. self.groupImageView.image = postImage;
  39. [self setNeedsLayout];
  40. }];
  41. NSString *curStr1 = [NSString stringWithFormat:@"%@",model.name];
  42. NSString *curStr2 = [NSString stringWithFormat:@"%ld",(long)model.count];
  43. NSString *totalStr = [[NSString alloc] initWithFormat:@"%@\n%@",curStr1,curStr2];
  44. NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
  45. NSRange redRange = NSMakeRange([totalStr rangeOfString:curStr2].location, [totalStr rangeOfString:curStr2].length);
  46. [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#959799" alpha:1.0] range:redRange];
  47. [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14.0] range:redRange];
  48. // 设置行间距
  49. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  50. [paragraphStyle setLineSpacing:5]; //设置行间距
  51. [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr length])];
  52. self.groupTextLabel.attributedText = noteStr;
  53. //self.groupTextLabel.text = ;
  54. if (self.selectButton == nil) {
  55. UIButton *but = [[UIButton alloc] init];
  56. [but setBackgroundImage:[UIImage imageNamed:@"upload_file_uncheck"] forState:UIControlStateNormal];
  57. [but setBackgroundImage:[UIImage imageNamed:@"upload_file_check"] forState:UIControlStateSelected];
  58. [self.contentView addSubview:but];
  59. but.userInteractionEnabled = NO;
  60. but.frame = CGRectMake([UIScreen mainScreen].bounds.size.width- 15- 25, (60 - 25)/2.0, 25, 25);
  61. // [but mas_makeConstraints:^(MASConstraintMaker *make) {
  62. // make.width.mas_equalTo(20);
  63. // make.height.mas_equalTo(20);
  64. // make.right.mas_equalTo(-15);
  65. // make.centerY.equalTo(self.contentView.mas_centerX).offset(0.f);
  66. // }];
  67. self.selectButton = but;
  68. }
  69. self.selectButton.selected = NO;
  70. }
  71. @end