OnLineTableViewCell.m 8.76 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
//
//  OnLineTableViewCell.m
//  redstar
//
//  Created by admin on 15/11/1.
//  Copyright © 2015年 ZWF. All rights reserved.
//

#import "OnLineTableViewCell.h"

@implementation OnLineTableViewCell
#pragma mark - System Methods
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setup];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

#pragma mark - Private Methods
- (void)setup
{
    self.titleLabel.textColor = kOnLineCellTitleColor;
admin's avatar
admin committed
31
    
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
}

#pragma mark - lazy loading
- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
        _titleLabel.font = [UIFont systemFontOfSize:16.0];
        [self.contentView addSubview:_titleLabel];
        
        // 顶端
        NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
        [self.contentView addConstraint:titleTop];
        
        // 左边
        NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
        [self.contentView addConstraint:titleLeft];
        
        // 右边
admin's avatar
admin committed
52
        NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:65];
53 54 55 56 57
        [self.contentView addConstraint:titleRight];
        
        // 高度
        NSLayoutConstraint *titleBottom = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
        [self.contentView addConstraint:titleBottom];
admin's avatar
admin committed
58 59 60
        // 高度
        NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_titleLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:50];
        [self.contentView addConstraint:titleHeight];
61 62 63 64 65 66 67 68 69 70

    }
    return _titleLabel;
}

#pragma mark - lazy loading
- (UILabel *)selectLabel
{
    if (!_selectLabel) {
        _selectLabel = [[UILabel alloc] init];
admin's avatar
admin committed
71
        _selectLabel.textColor = kOnLineCellDetailColor;
72 73 74 75 76 77 78 79 80 81
        _selectLabel.textAlignment = NSTextAlignmentRight;
        _selectLabel.translatesAutoresizingMaskIntoConstraints = NO;
        _selectLabel.font = [UIFont systemFontOfSize:15.0];
        [self.contentView addSubview:_selectLabel];
        
        // 顶端
        NSLayoutConstraint *selectTop = [NSLayoutConstraint constraintWithItem:_selectLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
        [self.contentView addConstraint:selectTop];
        
        // 左边
82
        NSLayoutConstraint *selectRight = [NSLayoutConstraint constraintWithItem:_selectLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-10];
83 84
        [self.contentView addConstraint:selectRight];
        
admin's avatar
admin committed
85
         // 右边
86
        NSLayoutConstraint *selectWidth = [NSLayoutConstraint constraintWithItem:_selectLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.titleLabel attribute:NSLayoutAttributeRight multiplier:1.0 constant:10];
admin's avatar
admin committed
87 88
        [self.contentView addConstraint:selectWidth];
//
89 90 91 92 93 94 95
        // 高度
        NSLayoutConstraint *selectBottom = [NSLayoutConstraint constraintWithItem:_selectLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
        [self.contentView addConstraint:selectBottom];
    }
    return _selectLabel;
}

admin's avatar
admin committed
96 97 98 99
- (UIButton *)storeBtn
{
    if (!_storeBtn) {
        _storeBtn = [[UIButton alloc] init];
admin's avatar
admin committed
100
        _storeBtn.tag = 323228;
admin's avatar
admin committed
101 102
        [_storeBtn setTitleColor:kOnLineCellTitleColor forState:UIControlStateNormal];
        _storeBtn.translatesAutoresizingMaskIntoConstraints = NO;
admin's avatar
admin committed
103
        [_storeBtn setTitle:@"商场得分" forState:UIControlStateNormal];
admin's avatar
admin committed
104
        [_storeBtn setImage:[UIImage imageNamed:@"select_box"] forState:UIControlStateNormal];
admin's avatar
admin committed
105
        [_storeBtn setImage:[UIImage imageNamed:@"no_select_box"] forState:UIControlStateSelected];
admin's avatar
admin committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
        _storeBtn.titleLabel.font = [UIFont systemFontOfSize:15.0f];
        _storeBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 20);
        _storeBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
        _storeBtn.imageView.contentMode = UIViewContentModeRight;
        _storeBtn.titleLabel.contentMode = UIViewContentModeLeft;
        [self.contentView addSubview:_storeBtn];
        
        // 顶端
        NSLayoutConstraint *selectTop = [NSLayoutConstraint constraintWithItem:_storeBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
        [self.contentView addConstraint:selectTop];
        
        // 左边
        NSLayoutConstraint *selectRight = [NSLayoutConstraint constraintWithItem:_storeBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-122];
        [self.contentView addConstraint:selectRight];
        
        // 右边
        NSLayoutConstraint *selectWidth = [NSLayoutConstraint constraintWithItem:_storeBtn attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:80];
        [self.contentView addConstraint:selectWidth];
        
        // 高度
        NSLayoutConstraint *selectBottom = [NSLayoutConstraint constraintWithItem:_storeBtn attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
        [self.contentView addConstraint:selectBottom];
    }
    return _storeBtn;
}


- (UIButton *)averageBtn
{
    if (!_averageBtn) {
        _averageBtn = [[UIButton alloc] init];
admin's avatar
admin committed
137
        _averageBtn.tag = 323229;
admin's avatar
admin committed
138 139
        [_averageBtn setTitleColor:kOnLineCellTitleColor forState:UIControlStateNormal];
        _averageBtn.translatesAutoresizingMaskIntoConstraints = NO;
admin's avatar
admin committed
140
        [_averageBtn setTitle:@"区域平均分" forState:UIControlStateNormal];
admin's avatar
admin committed
141
        [_averageBtn setImage:[UIImage imageNamed:@"select_box"] forState:UIControlStateNormal];
admin's avatar
admin committed
142
        [_averageBtn setImage:[UIImage imageNamed:@"no_select_box"] forState:UIControlStateSelected];
admin's avatar
admin committed
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
        _averageBtn.titleLabel.font = [UIFont systemFontOfSize:15.0f];
        _averageBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 20);
        _averageBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
        _averageBtn.imageView.contentMode = UIViewContentModeRight;
        _averageBtn.titleLabel.contentMode = UIViewContentModeLeft;
        [self.contentView addSubview:_averageBtn];
        
        // 顶端
        NSLayoutConstraint *selectTop = [NSLayoutConstraint constraintWithItem:_averageBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
        [self.contentView addConstraint:selectTop];
        
        // 左边
        NSLayoutConstraint *selectRight = [NSLayoutConstraint constraintWithItem:_averageBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-18];
        [self.contentView addConstraint:selectRight];
        
        // 右边
        NSLayoutConstraint *selectWidth = [NSLayoutConstraint constraintWithItem:_averageBtn attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:95];
        [self.contentView addConstraint:selectWidth];
        
        // 高度
        NSLayoutConstraint *selectBottom = [NSLayoutConstraint constraintWithItem:_averageBtn attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
        [self.contentView addConstraint:selectBottom];

    }
    return _averageBtn;
}
169
@end