123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- //
- // FKGroupAdvertCell.m
- // FirstLink
- //
- // Created by jack on 15/10/8.
- // Copyright © 2015年 FirstLink. All rights reserved.
- //
- #import "FKGroupMainImgCell.h"
- @interface FKGroupMainImgCell ()
- @property (nonatomic, strong) UILabel *stateLabel;
- @end
- @implementation FKGroupMainImgCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- [self addAllSubviews];
- }
- return self;
- }
- - (void)addAllSubviews{
- [self.contentView addSubview:self.mainImgView];
- [self.contentView addSubview:self.stateLabel];
-
- [self.mainImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.insets(UIEdgeInsetsZero);
- }];
-
- [self.stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.bottom.equalTo(self.contentView);
- make.width.mas_equalTo(100);
- make.height.mas_equalTo(39);
- }];
- }
- + (CGFloat)defaultHeight{
- return UISCREENWIDTH * 185 / 375.0;
- }
- + (NSString *)cdnImgUrlStringWithString:(NSString *)imgUrl
- {
- return [NSString stringWithFormat:@"%@%@", imgUrl,
- [FLStringHelper cdnParamaterString:(int)UISCREENWIDTH
- height:[FKGroupMainImgCell defaultHeight]]];
- }
- #pragma mark - property
- - (UIImageView *)mainImgView{
- if (_mainImgView == nil) {
- _mainImgView = [[UIImageView alloc]init];
- }
- return _mainImgView;
- }
- - (UILabel *)stateLabel{
- if (_stateLabel == nil) {
- _stateLabel = [[UILabel alloc]init];
- _stateLabel.backgroundColor = [UIColorFromRGB(0x49d0bb) colorWithAlphaComponent:0.5];
- _stateLabel.textColor = [UIColor whiteColor];
- _stateLabel.font = [UIFont systemFontOfSize:15];
- _stateLabel.textAlignment = NSTextAlignmentCenter;
- }
- return _stateLabel;
- }
- - (void)configWihtState:(GroupState)state postStatus:(kGroupPostStatus)postStatus{
-
- if (postStatus == kGroupPostStatusEnd) {
- self.stateLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
- self.stateLabel.text = @"拼团已结束";
- return;
- }
-
- UIColor *targetColor = nil;
- NSString *title = nil;
-
- switch (state) {
- case GroupStateNormal:{
- targetColor = [UIColorFromRGB(0x49d0bb) colorWithAlphaComponent:0.7];
- title = @"拼团进行中";
- }
- break;
- case GroupStateSuccess:{
- targetColor = [UIColorFromRGB(0xff624a) colorWithAlphaComponent:0.7];
- title = @"人数已满";
- }
-
- break;
- case GroupStateEnd:{
- targetColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
- title = @"拼团已结束";
- }
- break;
- default:
- break;
- }
- if (targetColor) self.stateLabel.backgroundColor = targetColor;
- self.stateLabel.text = title;
-
- }
- @end
|