HeaderCell.m 1.44 KB
Newer Older
n22's avatar
n22 committed
1 2 3 4 5 6 7 8 9 10 11 12
//
//  HeaderCell.m
//  XFFruit
//
//  Created by n22 on 15/8/19.
//  Copyright (c) 2015年 Xummer. All rights reserved.
//

#import "HeaderCell.h"
//#define HeadWidth 70
#define TitleSize 15
#define LeftMargin 13
n22's avatar
n22 committed
13 14
#define LeftWidth 45
#define RightWidth 30
n22's avatar
n22 committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#define SpaceMargin 1
@interface HeaderCell ()
@property (nonatomic,strong)NSArray *arr;
@property (nonatomic,strong)UILabel *lineLabel;

@end

@implementation HeaderCell

- (instancetype)initWithFrame:(CGRect)frame withArr:(NSArray *)arr{
    self = [super initWithFrame:frame];
    if (self) {
        self.arr = arr;
        [self bulidLayout];
    }
    return self;
}
- (void)bulidLayout{

n22's avatar
n22 committed
34
    CGFloat headWidth = (ScreenSize.width - LeftWidth - RightWidth - SpaceMargin* (self.arr.count -1))/self.arr.count;
n22's avatar
n22 committed
35 36 37
    for (NSInteger i = 0; i < self.arr.count; i++) {
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(LeftWidth + (SpaceMargin + headWidth)*i, 0, headWidth, self.frame.size.height)];
        label.font = FontSize(TitleSize);
n22's avatar
n22 committed
38
        label.textAlignment = NSTextAlignmentLeft;
n22's avatar
n22 committed
39 40 41 42 43 44 45 46 47 48
        label.textColor = HexColor(@"bbbbbb");
        label.text = self.arr[i];
        [self addSubview:label];
    }
    self.lineLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, self.frame.size.height-1, ScreenSize.width - LeftMargin * 2, 1))];
    self.lineLabel.backgroundColor = HexColor(@"e5e5e5");
    self.lineLabel.font = FontSize(TitleSize);
    [self addSubview:self.lineLabel];
}
@end