//
//  GoldHouseTableViewCell.m
//  Open
//
//  Created by 雷俊博 on 2021/4/14.
//  Copyright © 2021 黄江涛 . All rights reserved.
//

#import "GoldHouseTableViewCell.h"

@interface GoldHouseTableViewCell ()

@property (nonatomic, strong)UIView* containView;

@end

@implementation GoldHouseTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self setupUI];
    }
    
    return self;
}

- (void)setupUI
{
    //容器
    self.containView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 355 * WIDTHRADIU, 157 * WIDTHRADIU)];
    self.containView.center = self.contentView.center;
    self.containView.layer.cornerRadius = 10 * WIDTHRADIU;
    self.containView.layer.masksToBounds = YES;
    [self.contentView addSubview:self.containView];
    
    //添加渐变背景色
    CAGradientLayer *gradientLayer = [[CAGradientLayer alloc] init];
    gradientLayer.colors = @[(__bridge id)[UIColor colorWithHex:0xfffffd].CGColor,(__bridge id)[UIColor colorWithHex:0xfef4cc].CGColor];
    gradientLayer.startPoint = CGPointMake(1, 0);
    gradientLayer.endPoint = CGPointMake(1, 1);
    gradientLayer.frame = CGRectMake(0, 0, CGRectGetWidth(self.containView.frame), CGRectGetHeight(self.containView.frame));

    [self.containView.layer addSublayer:gradientLayer];
    
    //背景title图片
    UIImageView *goldIcon = [[UIImageView alloc]init];
    goldIcon.image = [UIImage imageNamed:@"littleGoldHouse"];
    [self.containView addSubview:goldIcon];
    [goldIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.centerX.equalTo(self.containView);
        make.width.offset(220 * WIDTHRADIU);
        make.height.offset(32 * WIDTHRADIU);
    }];
    
    //主标题
    UILabel *lb_title = [UILabel new];
    lb_title.text = @"爱理财、爱生活";
    lb_title.textAlignment = NSTextAlignmentCenter;
    lb_title.font = [UIFont boldSystemFontOfSize:24 * WIDTHRADIU];
    lb_title.textColor = [UIColor colorWithHex:0xb15e13];
    [self.containView addSubview:lb_title];
    [lb_title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(goldIcon.mas_bottom).offset(10 * WIDTHRADIU);
        make.centerX.equalTo(self.containView);
    }];
    
    //副标题
    UILabel *lb_subTitle = [UILabel new];
    lb_subTitle.text = @"享收益、灵活取、便捷花";
    lb_subTitle.textAlignment = NSTextAlignmentCenter;
    lb_subTitle.font = [UIFont systemFontOfSize:14 * WIDTHRADIU];
    lb_subTitle.textColor = [UIColor colorWithHex:0x666666];
    [self.containView addSubview:lb_subTitle];
    [lb_subTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lb_title.mas_bottom).offset(5 * WIDTHRADIU);
        make.centerX.equalTo(self.containView);
    }];
    
    //按钮
    UIButton *checkBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    checkBtn.backgroundColor = [UIColor colorWithHex:0xfcd25c];
    [checkBtn setTitle:@"立即查看" forState:UIControlStateNormal];
    [checkBtn setTitleColor:[UIColor colorWithHex:0xb15e13] forState:UIControlStateNormal];
    checkBtn.titleLabel.font = [UIFont systemFontOfSize:16 * WIDTHRADIU];
    checkBtn.layer.cornerRadius = 20 * WIDTHRADIU;
    checkBtn.layer.masksToBounds = YES;
    
    [checkBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lb_subTitle.mas_bottom).offset(28 * WIDTHRADIU);
        make.centerX.equalTo(self.containView);
        make.width.offset(150 * WIDTHRADIU);
        make.height.offset(40 * WIDTHRADIU);
    }];
    
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
