HomeTitleTableCell.m 5.69 KB
Newer Older
admin's avatar
admin committed
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
//
//  HomeTitleTableCell.m
//  redstar
//
//  Created by admin on 15/11/16.
//  Copyright © 2015年 ZWF. All rights reserved.
//

#import "HomeTitleTableCell.h"

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

- (void)setup
{
    // 商场
    UILabel *shoppingLabel = [[UILabel alloc] init];
    shoppingLabel.text = @"商场名称";
admin's avatar
admin committed
26
    shoppingLabel.backgroundColor = [UIColor clearColor];
admin's avatar
admin committed
27 28 29 30 31 32 33 34 35
    shoppingLabel.textAlignment = NSTextAlignmentCenter;
    shoppingLabel.textColor = kRankHeadTitleTextColor;
    shoppingLabel.font = [UIFont systemFontOfSize:17.0];
    shoppingLabel.translatesAutoresizingMaskIntoConstraints = NO;
    [self.contentView addSubview:shoppingLabel];
    
    // 总分
    UILabel *scoreLabel = [[UILabel alloc] init];
    scoreLabel.text = @"总分";
admin's avatar
admin committed
36 37
    scoreLabel.backgroundColor = [UIColor clearColor];

admin's avatar
admin committed
38 39 40 41 42 43 44 45 46
    scoreLabel.textAlignment = NSTextAlignmentCenter;
    scoreLabel.textColor = kRankHeadTitleTextColor;
    scoreLabel.font = [UIFont systemFontOfSize:17.0];
    scoreLabel.translatesAutoresizingMaskIntoConstraints = NO;
    [self.contentView addSubview:scoreLabel];
    
    // 排名
    UILabel *gradeLabel = [[UILabel alloc] init];
    gradeLabel.text = @"排名";
admin's avatar
admin committed
47
    gradeLabel.backgroundColor = [UIColor clearColor];
admin's avatar
admin committed
48 49 50 51 52 53 54
    gradeLabel.textAlignment = NSTextAlignmentCenter;
    gradeLabel.textColor = kRankHeadTitleTextColor;
    gradeLabel.font = [UIFont systemFontOfSize:17.0];
    gradeLabel.translatesAutoresizingMaskIntoConstraints = NO;
    [self.contentView addSubview:gradeLabel];
    
    //
admin's avatar
admin committed
55
    NSLayoutConstraint *shoppingTop = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:3];
admin's avatar
admin committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
    [self.contentView addConstraint:shoppingTop];
    
    NSLayoutConstraint *shoppingLeft = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
    [self.contentView addConstraint:shoppingLeft];
    
    NSLayoutConstraint *shoppingRight = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:scoreLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
    [self.contentView addConstraint:shoppingRight];
    
    NSLayoutConstraint *shoppingBottom = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
    [self.contentView addConstraint:shoppingBottom];
    
    NSLayoutConstraint *shoppingWidth = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:scoreLabel attribute:NSLayoutAttributeWidth multiplier:1.2 constant:0];
    [self.contentView addConstraint:shoppingWidth];
    
    //
admin's avatar
admin committed
71
    NSLayoutConstraint *scoreTop = [NSLayoutConstraint constraintWithItem:scoreLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:3];
admin's avatar
admin committed
72 73 74 75 76 77 78 79 80 81 82 83
    [self.contentView addConstraint:scoreTop];
    
    NSLayoutConstraint *scoreRight = [NSLayoutConstraint constraintWithItem:scoreLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:gradeLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
    [self.contentView addConstraint:scoreRight];
    
    NSLayoutConstraint *scoreWidth = [NSLayoutConstraint constraintWithItem:scoreLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:gradeLabel attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0];
    [self.contentView addConstraint:scoreWidth];
    
    NSLayoutConstraint *scoreBottom = [NSLayoutConstraint constraintWithItem:scoreLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
    [self.contentView addConstraint:scoreBottom];
    
    //
admin's avatar
admin committed
84
    NSLayoutConstraint *gradeTop = [NSLayoutConstraint constraintWithItem:gradeLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:3];
admin's avatar
admin committed
85 86 87 88 89 90 91
    [self.contentView addConstraint:gradeTop];
    
    NSLayoutConstraint *gradeRight = [NSLayoutConstraint constraintWithItem:gradeLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
    [self.contentView addConstraint:gradeRight];
    
    NSLayoutConstraint *gradeBottom = [NSLayoutConstraint constraintWithItem:gradeLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
    [self.contentView addConstraint:gradeBottom];
92 93 94
    
    NSLayoutConstraint *shoppingHheight = [NSLayoutConstraint constraintWithItem:gradeLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.2 constant:30];
    [self.contentView addConstraint:shoppingHheight];
admin's avatar
admin committed
95 96 97 98 99 100 101 102 103 104 105 106 107 108
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end