No Description

FKGroupMainImgCell.m 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // FKGroupAdvertCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 15/10/8.
  6. // Copyright © 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "FKGroupMainImgCell.h"
  9. @interface FKGroupMainImgCell ()
  10. @property (nonatomic, strong) UILabel *stateLabel;
  11. @end
  12. @implementation FKGroupMainImgCell
  13. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  14. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  15. self.selectionStyle = UITableViewCellSelectionStyleNone;
  16. [self addAllSubviews];
  17. }
  18. return self;
  19. }
  20. - (void)addAllSubviews{
  21. [self.contentView addSubview:self.mainImgView];
  22. [self.contentView addSubview:self.stateLabel];
  23. [self.mainImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.edges.insets(UIEdgeInsetsZero);
  25. }];
  26. [self.stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.left.bottom.equalTo(self.contentView);
  28. make.width.mas_equalTo(100);
  29. make.height.mas_equalTo(39);
  30. }];
  31. }
  32. + (CGFloat)defaultHeight{
  33. return UISCREENWIDTH * 185 / 375.0;
  34. }
  35. + (NSString *)cdnImgUrlStringWithString:(NSString *)imgUrl
  36. {
  37. return [NSString stringWithFormat:@"%@%@", imgUrl,
  38. [FLStringHelper cdnParamaterString:(int)UISCREENWIDTH
  39. height:[FKGroupMainImgCell defaultHeight]]];
  40. }
  41. #pragma mark - property
  42. - (UIImageView *)mainImgView{
  43. if (_mainImgView == nil) {
  44. _mainImgView = [[UIImageView alloc]init];
  45. }
  46. return _mainImgView;
  47. }
  48. - (UILabel *)stateLabel{
  49. if (_stateLabel == nil) {
  50. _stateLabel = [[UILabel alloc]init];
  51. _stateLabel.backgroundColor = [UIColorFromRGB(0x49d0bb) colorWithAlphaComponent:0.5];
  52. _stateLabel.textColor = [UIColor whiteColor];
  53. _stateLabel.font = [UIFont systemFontOfSize:15];
  54. _stateLabel.textAlignment = NSTextAlignmentCenter;
  55. }
  56. return _stateLabel;
  57. }
  58. - (void)configWihtState:(GroupState)state postStatus:(kGroupPostStatus)postStatus{
  59. if (postStatus == kGroupPostStatusEnd) {
  60. self.stateLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
  61. self.stateLabel.text = @"拼团已结束";
  62. return;
  63. }
  64. UIColor *targetColor = nil;
  65. NSString *title = nil;
  66. switch (state) {
  67. case GroupStateNormal:{
  68. targetColor = [UIColorFromRGB(0x49d0bb) colorWithAlphaComponent:0.7];
  69. title = @"拼团进行中";
  70. }
  71. break;
  72. case GroupStateSuccess:{
  73. targetColor = [UIColorFromRGB(0xff624a) colorWithAlphaComponent:0.7];
  74. title = @"人数已满";
  75. }
  76. break;
  77. case GroupStateEnd:{
  78. targetColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
  79. title = @"拼团已结束";
  80. }
  81. break;
  82. default:
  83. break;
  84. }
  85. if (targetColor) self.stateLabel.backgroundColor = targetColor;
  86. self.stateLabel.text = title;
  87. }
  88. @end