//
//  ChannelHeaderView.swift
//  SYMobilePortal
//
//  Created by xiejiangbo on 2018/5/8.
//  Copyright © 2018年 yin chen. All rights reserved.
//

import UIKit

class ChannelHeaderView: UICollectionReusableView {
    
    var text: String? {
        didSet {
            label.text = text
            if text == "我的常用" || text == "我的应用" {
                label.frame = CGRect(x:10, y: 0, width:getTexWidth(textStr: text!, font: UIFont.systemFont(ofSize: 16), height: self.height) , height:self.height )
                backgroundColor = moreClassColor
                lineView.isHidden = true
            }else{
                addSubview(lineView)
                lineView.isHidden = false
                lineView.frame = CGRect(x:label.originX+label.width, y: 0, width:self.width-label.originX+label.width , height:0.5 )
                lineView.centerY = self.height/2
            }
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    private func setupUI() {
        addSubview(label)
       
        //backgroundColor = UIColor.groupTableViewBackground
        //
    }
    private lazy var lineView: UIImageView = {
        let lineView = UIImageView.init()
        lineView.backgroundColor = blackTitleColor
        lineView.alpha = 0.4
        lineView.isHidden = true
        return lineView
    }()
    private lazy var label: UILabel = {
        let label = UILabel(frame: CGRect(x:10, y: 0, width:35 , height:self.height ))
        //label.frame.origin.x = 20
        label.textColor = blackTitleColor
        label.font = UIFont.systemFont(ofSize: 13)
        label.font = UIFont.boldSystemFont(ofSize: 13)
        //label.font = UIFont.init(name: "Arial Rounded MT Bold", size: 13)
        return label
    }()
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
