//
//  TitleView.swift
//  MobilePortal
//
//  Created by caiyang on 2020/4/8.
//  Copyright © 2020 yin chen. All rights reserved.
//

import UIKit

class TitleView: UIView {

    lazy var titleLabel: UILabel = {
        let titleLabel = UILabel.init()
        titleLabel.textAlignment = .left
        titleLabel.numberOfLines = 0
//        titleLabel.font = UIFont.systemFont(ofSize: 21.33)
        titleLabel.font = UIFont.test_boldSystemFont(21.33)
        titleLabel.font = UIFont.test_font(withName: 21.33)
        titleLabel.textColor = UIColorFromRGB(rgbValue: 0x1E202C)
        self.addSubview(titleLabel)
        return titleLabel
    }()
    lazy var subImageView: UIImageView = {
        let subImageView = UIImageView.init()
        //subImageView.contentMode = .scaleToFill
        subImageView.contentMode = .scaleAspectFill
//        subImageView.backgroundColor = UIColor.yellow
        subImageView.image = UIImage.init(named: "bigQ_image")
        self.addSubview(subImageView)
        return subImageView
    }()
    var text: String? {
        didSet {
            titleLabel.frame = CGRect(x:19.33, y: 30, width:self.width-20 , height:getTextHeigh(textStr: text!, font: UIFont.systemFont(ofSize: 21.33), width: self.width-20) )
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.subImageView.frame = CGRect(x:0, y: 0, width:46.67 , height:64.67 )
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
