AJPhotoGroupCell.m 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. [self.contentView addSubview:textLabel];
  34. self.groupTextLabel = textLabel;
  35. }
  36. [[TZImageManager manager] getPostImageWithAlbumModel:model completion:^(UIImage *postImage) {
  37. self.groupImageView.image = postImage;
  38. [self setNeedsLayout];
  39. }];
  40. NSString *curStr1 = [NSString stringWithFormat:@"%@",model.name];
  41. NSString *curStr2 = [NSString stringWithFormat:@"%ld",(long)model.count];
  42. NSString *totalStr = [[NSString alloc] initWithFormat:@"%@\n%@",curStr1,curStr2];
  43. NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
  44. NSRange redRange = NSMakeRange([totalStr rangeOfString:curStr2].location, [totalStr rangeOfString:curStr2].length);
  45. [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#959799" alpha:1.0] range:redRange];
  46. [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14.0] range:redRange];
  47. // 设置行间距
  48. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  49. [paragraphStyle setLineSpacing:5]; //设置行间距
  50. [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr length])];
  51. self.groupTextLabel.attributedText = noteStr;
  52. //self.groupTextLabel.text = ;
  53. if (self.selectButton == nil) {
  54. UIButton *but = [[UIButton alloc] init];
  55. [but setBackgroundImage:[UIImage imageNamed:@"upload_file_uncheck"] forState:UIControlStateNormal];
  56. [but setBackgroundImage:[UIImage imageNamed:@"upload_file_check"] forState:UIControlStateSelected];
  57. [self.contentView addSubview:but];
  58. but.frame = CGRectMake([UIScreen mainScreen].bounds.size.width- 15- 25, (60 - 25)/2.0, 25, 25);
  59. // [but mas_makeConstraints:^(MASConstraintMaker *make) {
  60. // make.width.mas_equalTo(20);
  61. // make.height.mas_equalTo(20);
  62. // make.right.mas_equalTo(-15);
  63. // make.centerY.equalTo(self.contentView.mas_centerX).offset(0.f);
  64. // }];
  65. self.selectButton = but;
  66. }
  67. self.selectButton.selected = NO;
  68. }
  69. @end