//
//  YBButton.m
//  YBPlaying
//
//  Created by IOS1 on 2019/11/4.
//  Copyright © 2019 IOS1. All rights reserved.
//

#import "WYButton.h"

@implementation WYButton


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
    [self addSubview:self.showImgView];
    [_showImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.centerX.equalTo(self);
        make.width.equalTo(self);
        make.height.equalTo(_showImgView.mas_width);
    }];
    [self addSubview:self.showTitleLabel];
    [_showTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.bottom.equalTo(self);
    }];
}
- (UIImageView *)showImgView{
    if (!_showImgView) {
        _showImgView = [[UIImageView alloc]init];
        _showImgView.contentMode = UIViewContentModeScaleAspectFill;
        _showImgView.clipsToBounds = YES;
        _showImgView.image = _showImage;
    }
    return _showImgView;
}
- (UILabel *)showTitleLabel{
    if (!_showTitleLabel) {
        _showTitleLabel = [[UILabel alloc]init];
        _showTitleLabel.font = _textFont ? _textFont : SYS_Font(13);
        _showTitleLabel.textColor = _textColoro ? _textColoro : color96;
        _showTitleLabel.text = _showText;
    }
    return _showTitleLabel;
}
- (void)setShowImage:(UIImage *)showImage{
    _showImage = showImage;
    _showImgView.image = _showImage;
}
-(void)setShowText:(NSString *)showText{
    _showText = showText;
    _showTitleLabel.text = _showText;
}
@end
