//
//  NoDataView.m
//  Open
//
//  Created by 雷俊博 on 2019/9/5.
//  Copyright © 2019 黄江涛 . All rights reserved.
//

#import "NoDataView.h"

#import "Constants.h"

#import <Masonry.h>

@interface NoDataView ()

@property (nonatomic,strong)UIImageView *img_icon;

@property (nonatomic, strong)UILabel *lb_message;

@end

@implementation NoDataView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addSubview:self.img_icon];
        [self addSubview:self.lb_message];
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    [self.img_icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.offset(116 * WIDTHRADIU);
    }];
    
    [self.lb_message mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(self.img_icon.mas_bottom).offset(14 * WIDTHRADIU);
    }];
}
#pragma mark - getters and setters
- (UIImageView *)img_icon
{
    if (!_img_icon) {
        _img_icon = [[UIImageView alloc]init];
        _img_icon.image = [UIImage imageNamed:@"我的奖品-空状态"];
    }
    return _img_icon;
}

- (UILabel *)lb_message
{
    if (!_lb_message) {
        _lb_message = [[UILabel alloc]init];
        _lb_message.numberOfLines = 0;
        _lb_message.font = [UIFont systemFontOfSize:15 * WIDTHRADIU];
        _lb_message.textColor = [UIColor colorWithHex:0xbfbfbf];
        NSString *str = @"暂无奖品，快去抽奖中心\n赢取更多礼品吧！";
        NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:str];
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
        paragraphStyle.lineSpacing = 10.0 * WIDTHRADIU; // 设置行间距
        paragraphStyle.alignment = NSTextAlignmentCenter; //设置两端对齐显示
        [attributedStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attributedStr.length)];
        _lb_message.attributedText = attributedStr;
        
    }
    return _lb_message;
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
