//
//  XBYStatusLabel.m
//  XBYTopTabBarViewController
//
//  Created by xiebangyao on 2017/12/27.
//  Copyright © 2017年 xby. All rights reserved.
//

#import "XBYStatusLabel.h"

@implementation XBYStatusLabel {
    int regularColorHex, selectedColorHex;
}

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.textAlignment = NSTextAlignmentCenter;
        self.font = [UIFont systemFontOfSize:20];
        
//        regularColorHex = 0x333333;
//        selectedColorHex = 0x1886d3;
        self.textColor = [UIColor colorWithHex:0x333333];
        
        self.scale = 0;
    }
    return self;
}

//0.8时colorHex为0x666666  1时colorHex为0x3285ff
- (void)setScale:(CGFloat)scale {
    if (scale < 0) {
        return;
    }
    _scale = scale;
    
    CGFloat minScale = 0.8;
    CGFloat realScale = minScale + (1 - minScale) * _scale;
    
//    int rhhex = (regularColorHex>>16), rmhex = (regularColorHex>>8)&0xff, rlhex = regularColorHex&0xff;
//    int shhex = (selectedColorHex>>16), smhex = (selectedColorHex>>8)&0xff, slhex = selectedColorHex&0xff;
//
//    int hHex = (rhhex - shhex) * (1 - realScale) / 0.2;
//    int mHex = (rmhex - smhex) * (1 - realScale) / 0.2;
//    NSInteger lHex = (rlhex - slhex) * (1 - realScale) / 0.2;
//
//    NSInteger colorHex = (shhex + hHex)*(1<<16) + (smhex + mHex)*(1<<8) + (slhex + lHex);
//    self.textColor = ColorFromRGB(colorHex);
    if (realScale < 1) {
        self.font = [UIFont systemFontOfSize:20];
    }else{
        self.font = [UIFont boldSystemFontOfSize:20];
    }
    self.transform = CGAffineTransformMakeScale(realScale, realScale);
    
        
}

- (void)setShowColor:(UIColor *)showColor
{
    _showColor = showColor;
    self.textColor = showColor;
}

@end
