123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- //
- // FKGroupStepCell.m
- // FirstLink
- //
- // Created by jack on 15/10/7.
- // Copyright © 2015年 FirstLink. All rights reserved.
- //
- #import "FKGroupStepCell.h"
- #define kNumLabelTagBase 1000
- #define kStepLabelTagBase 2000
- #define kAreaTagBase 500
- #define VIP_PROTOCOL_URL ([NSString stringWithFormat:@"%@/link-site/mobile/fightGroups/explain.html", [[FKServerUtil sharedInstance] apiServer]])
- @interface FKGroupStepCell ()
- @property (nonatomic, strong) UILabel *leftLabel;
- @property (nonatomic, strong) UILabel *rightLabel;
- @property (nonatomic, strong) UIImageView *rightArrow;
- @end
- @implementation FKGroupStepCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- [self addAllSubviews];
- }
- return self;
- }
- + (NSString *)pushExplainUrl{
- return VIP_PROTOCOL_URL;
- }
- - (void)addAllSubviews{
-
- UIView *area1 = [[UIView alloc]init];
- UIView *area2 = [[UIView alloc]init];
- UIView *area3 = [[UIView alloc]init];
- UIView *area4 = [[UIView alloc]init];
- [self.contentView addSubview:self.leftLabel];
- [self.contentView addSubview:self.rightLabel];
- [self.contentView addSubview:self.rightArrow];
- [self.contentView addSubview:area1];
- [self.contentView addSubview:area2];
- [self.contentView addSubview:area3];
- [self.contentView addSubview:area4];
- [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(10);
- make.top.equalTo(self.contentView).offset(10);
- }];
-
-
- [self.rightArrow mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.leftLabel);
- make.right.equalTo(self.contentView).offset(-12);
- }];
-
- [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.leftLabel);
- make.right.equalTo(self.rightArrow.mas_left).offset(-6);
- }];
-
- [area1 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.leftLabel.mas_bottom);
- make.left.bottom.equalTo(self.contentView);
- make.width.equalTo(self.contentView).multipliedBy(0.25);
- }];
-
- [area2 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(area1.mas_right);
- make.top.bottom.equalTo(area1);
- make.width.equalTo(self.contentView).multipliedBy(0.25);
- }];
-
- [area3 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(area2.mas_right);
- make.top.bottom.equalTo(area1);
- make.width.equalTo(self.contentView).multipliedBy(0.25);
- }];
-
- [area4 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(area3.mas_right);
- make.top.bottom.equalTo(area1);
- make.right.equalTo(self.contentView);
- }];
-
- [self configArea:area1 stepNum:kGroupStepSelect title:@"选择心仪\n的商品"];
- [self configArea:area2 stepNum:kGroupStepPay title:@"支付开团\n或参团"];
- [self configArea:area3 stepNum:kGroupStepInvite title:@"邀请好友\n参团支付"];
- [self configArea:area4 stepNum:kGroupStepFinish title:@"达到人数\n团购成功"];
- }
- - (void)configArea:(UIView *)area stepNum:(kGroupStep)step title:(NSString *)title{
-
- area.tag = kAreaTagBase + step;
- UIImageView *circle = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"xuCircle"]];
- UILabel *numLabel = [self createNumLabelWithText:[NSString stringWithFormat:@"%lu", ((unsigned long)step + 1)] tag:kNumLabelTagBase + step];
- UILabel *titleLabel = [self createLabelWithTitle:title tag:kStepLabelTagBase + step];
-
- [area addSubview:circle];
- [area addSubview:numLabel];
- [area addSubview:titleLabel];
-
- // UI布局适配
- CGFloat margin = 10;
- CGFloat titleMargin = 8;
- if (step != kGroupStepSelect && (IS_IPHONE_4 || IS_IPHONE_5)) margin = 5;
- if (IS_IPHONE_4 || IS_IPHONE_5) titleMargin = 4;
-
- [circle mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(area).offset(margin);
- make.centerY.equalTo(area);
- }];
-
- [numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.equalTo(circle);
- make.width.height.mas_equalTo(20);
- }];
-
-
- [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(circle.mas_right).offset(titleMargin);
- make.centerY.equalTo(circle);
- }];
- }
- - (UILabel *)createNumLabelWithText:(NSString *)text tag:(NSUInteger)tag{
- UILabel *label = [[UILabel alloc]init];
- label.textColor = UIColorFromRGB(0x666666);
- label.layer.cornerRadius = 10;
- label.layer.masksToBounds = YES;
- label.textAlignment = NSTextAlignmentCenter;
- label.font = [UIFont boldSystemFontOfSize:12];
- label.tag = tag;
- label.text = text;
- return label;
- }
- - (UILabel *)createLabelWithTitle:(NSString *)title tag:(NSUInteger)tag{
- UILabel *label = [[UILabel alloc]init];
- label.text = title;
- label.tag = tag;
- label.font = [UIFont systemFontOfSize:11];
- label.textColor = UIColorFromRGB(0x666666);
- label.numberOfLines = 0;
- return label;
- }
- - (void)setStep:(kGroupStep)step{
-
- UIView *area = [self.contentView viewWithTag:kAreaTagBase + step];
- UILabel *numLabel = (UILabel *)[area viewWithTag:kNumLabelTagBase + step];
- UILabel *titleLabel = (UILabel *)[area viewWithTag:kStepLabelTagBase + step];
-
- if (numLabel) {
- numLabel.backgroundColor = UIColorFromRGB(0x49d0bb);
- numLabel.textColor = [UIColor whiteColor];
- }
-
- if (titleLabel){
- titleLabel.textColor = UIColorFromRGB(0x49d0bb);
- }
- }
- - (UILabel *)leftLabel{
- if (_leftLabel == nil) {
- _leftLabel = [[UILabel alloc]init];
- _leftLabel.textColor = UIColorFromRGB(0x999999);
- _leftLabel.font = [UIFont systemFontOfSize:11];
- _leftLabel.text = @"拼团玩法";
- }
- return _leftLabel;
- }
- - (UILabel *)rightLabel{
- if (_rightLabel == nil) {
- _rightLabel = [[UILabel alloc]init];
- _rightLabel.textColor = UIColorFromRGB(0x333333);
- _rightLabel.font = [UIFont systemFontOfSize:12];
- _rightLabel.text = @"活动详情";
- }
- return _rightLabel;
- }
- - (UIImageView *)rightArrow{
- if (_rightArrow == nil) {
- _rightArrow = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"groupRightArrow_small"]];
- }
- return _rightArrow;
- }
- @end
|