//
//  SearchTextField.swift
//  MobilePortal
//
//  Created by xiejiangbo on 2019/3/20.
//  Copyright © 2019 yin chen. All rights reserved.
//

import UIKit

class SearchTextField: UITextField {
    lazy var leftSearchView : UIImageView = {
        let leftSearchView = UIImageView.init(frame: CGRect(x:0, y: 7, width: 30*WHIDTH_RATIO() , height:14 ))
        leftSearchView.image = UIImage.init(named: "search_image")
        leftSearchView.contentMode = .scaleAspectFit
        return leftSearchView;
    }()
    override init(frame:CGRect) {
        super.init(frame: frame)
        placeholder = "搜索"
        font = UIFont.systemFont(ofSize: 14)
//        setValue(UIFont.systemFont(ofSize: 14), forKeyPath: "_placeholderLabel.font")
        attributedPlaceholder = NSAttributedString.init(string:"搜索", attributes: [NSAttributedStringKey.font:UIFont.test_systemFont(ofSize: 14)])
        //字体颜色
        attributedPlaceholder = NSAttributedString.init(string:"搜索", attributes: [
                                                                NSAttributedStringKey.foregroundColor:placeholderColor])
        textColor = blackTitleColor
        background = UIImage.init(named: "searchTextField_Bagimage")
        borderStyle = .none
        leftView = leftSearchView
        leftViewMode = .always
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
