//
//  ICBatteryProgressView.m
//  superCleaner
//
//  Created by Mazy on 2020/7/31.
//  Copyright © 2020 Mazy. All rights reserved.
//

#import "ICBatteryProgressView.h"

@implementation ICBatteryProgressView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    self.backgroundColor = [UIColor whiteColor];
}

- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)drawRect:(CGRect)rect {
    [[UIColor whiteColor] set];
    UIBezierPath *bgPath = [UIBezierPath bezierPathWithRect:rect];
    [bgPath fillWithBlendMode: kCGBlendModeNormal alpha:1];

    if (self.value < 0.2) {
        [[UIColor colorWithHex:0xFDBD2C] set];
    } else {
        [kMassColor set];
    }
    CGRect progressRect = CGRectMake(0, 0, self.value * rect.size.width, rect.size.height);
    UIBezierPath *progressPath = [UIBezierPath bezierPathWithRoundedRect:progressRect cornerRadius: 2];
    [progressPath fillWithBlendMode: kCGBlendModeNormal alpha:1];
}

@end
