SaleHeaderView.m 2.55 KB
Newer Older
陈俊俊's avatar
陈俊俊 committed
1 2 3 4 5 6 7 8 9 10
//
//  SaleHeaderView.m
//  XFFruit
//
//  Created by 陈俊俊 on 15/11/8.
//  Copyright © 2015年 Xummer. All rights reserved.
//

#import "SaleHeaderView.h"

11
#define Sale_Header_Height 35
陈俊俊's avatar
陈俊俊 committed
12 13 14 15 16 17 18 19

@interface SaleHeaderView ()
{
    BOOL    hasBuildLayout;         // default, NO;
}

@property (nonatomic, strong) UILabel *label;
@property (nonatomic, strong) UIFont *textFont;
陈俊俊's avatar
陈俊俊 committed
20
@property (nonatomic, strong) UILabel *bszLabel;
陈俊俊's avatar
陈俊俊 committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

@end


@implementation SaleHeaderView


+ (CGFloat)viewHeight
{
    return Sale_Header_Height;
}

- (void)buildLayout
{
    if(hasBuildLayout) {
        return;
    }
    
    if(self.textFont == nil) {
陈俊俊's avatar
陈俊俊 committed
40
        self.textFont = [UIFont systemFontOfSize:13];
陈俊俊's avatar
陈俊俊 committed
41 42 43
    }
    
    hasBuildLayout = YES;
44 45 46 47 48
    self.contentView.backgroundColor = XXFBgColor;
    CGRect rect = CGRectMake(0, 0, ScreenSize.width, 1);
    UILabel *lineLabel = [[UILabel alloc]initWithFrame:rect];
    lineLabel.backgroundColor = GXF_LINE_COLOR;
    [self.contentView addSubview:lineLabel];
陈俊俊's avatar
陈俊俊 committed
49
    
50 51
    
    rect = CGRectMake(10, 0, 105, Sale_Header_Height);
陈俊俊's avatar
陈俊俊 committed
52 53
    UILabel *searLabel = [IBTCommon labelWithTitle:@"共280家" frame:rect textFont:self.textFont];
    searLabel.textColor = ReportTitleColor;
陈俊俊's avatar
陈俊俊 committed
54
    [self.contentView addSubview:searLabel];
陈俊俊's avatar
陈俊俊 committed
55
    self.totalLabel = searLabel;
陈俊俊's avatar
陈俊俊 committed
56
    
陈俊俊's avatar
陈俊俊 committed
57
    CGFloat width = (ScreenSize.width  - searLabel.right - 25)/3;
陈俊俊's avatar
陈俊俊 committed
58

陈俊俊's avatar
陈俊俊 committed
59
    rect = CGRectMake(searLabel.right, 0, width + 20, Sale_Header_Height);
陈俊俊's avatar
陈俊俊 committed
60 61
    UILabel * xsBtn = [IBTCommon labelWithTitle:@"销售额" frame:rect textFont:self.textFont];
    xsBtn.textColor = ReportTitleColor;
陈俊俊's avatar
陈俊俊 committed
62 63 64
    [self.contentView addSubview:xsBtn];
    
    rect = CGRectMake(xsBtn.right , 0, width, Sale_Header_Height);
陈俊俊's avatar
陈俊俊 committed
65 66
    UILabel * bszLabel = [IBTCommon labelWithTitle:@"比上周" frame:rect textFont:self.textFont];
    bszLabel.textColor = ReportTitleColor;
陈俊俊's avatar
陈俊俊 committed
67
    [self.contentView addSubview:bszLabel];
陈俊俊's avatar
陈俊俊 committed
68
    self.bszLabel = bszLabel;
陈俊俊's avatar
陈俊俊 committed
69
    
陈俊俊's avatar
陈俊俊 committed
70
    rect = CGRectMake(bszLabel.right , 0, width-20, Sale_Header_Height);
陈俊俊's avatar
陈俊俊 committed
71
    UILabel * sclLabel = [IBTCommon labelWithTitle:@"达成率" frame:rect textFont:self.textFont];
陈俊俊's avatar
陈俊俊 committed
72
    sclLabel.textColor = ReportTitleColor;
陈俊俊's avatar
陈俊俊 committed
73
    [self.contentView addSubview:sclLabel];
74 75 76 77 78
    
    rect = CGRectMake(0, Sale_Header_Height-1, ScreenSize.width, 1);
    UILabel *lineTLabel = [[UILabel alloc]initWithFrame:rect];
    lineTLabel.backgroundColor = GXF_LINE_COLOR;
    [self.contentView addSubview:lineTLabel];
陈俊俊's avatar
陈俊俊 committed
79 80
   
}
陈俊俊's avatar
陈俊俊 committed
81 82 83 84 85 86 87 88 89
- (void)changeTypeName:(NSString *)name{
    NSString *typeStr = @"";
    if ([name isEqualToString:SaleEnMonth]) {
        typeStr = LastMonth;
    }else{
        typeStr = LastWeak;
    }
    self.bszLabel.text = typeStr;
}
陈俊俊's avatar
陈俊俊 committed
90
@end