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

import UIKit

class WeixinQQView: UIView {

    var weixinBtn:UIButton!
    var weixinLabel:UILabel!
    var qqBtn:UIButton!
    var qqLabel:UILabel!
    
    var lineLabel:UILabel!
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        initLinView()
        initWeixinQQView()
    }

    override func layoutSubviews() {
        
        
    }
    func initLinView(){
        let leftView:UIImageView = self.getLinViewImage()
        leftView.frame = CGRect(x:WHIDTH_RATIO()*11, y: 0, width:WHIDTH_RATIO()*115 , height:HEIGHT_RATIO()*1)
        self.addSubview(leftView)
        
        lineLabel = UILabel.init(frame: CGRect(x:WHIDTH_RATIO()*11, y: 0, width:WHIDTH_RATIO()*100 , height:HEIGHT_RATIO()*13))
        lineLabel.centerX = self.centerX
        lineLabel.text = "第三方账号登录"
        lineLabel.textColor = grayColor
        lineLabel.font = UIFont.systemFont(ofSize: 13*WHIDTH_RATIO())
        lineLabel.textAlignment = .center
        self.addSubview(lineLabel)
        let rightView:UIImageView = self.getLinViewImage()
        rightView.frame = CGRect(x:self.width-WHIDTH_RATIO()*126, y: 0, width:WHIDTH_RATIO()*115 , height:HEIGHT_RATIO()*1)
        self.addSubview(rightView)
        rightView.centerY = lineLabel.centerY
        leftView.centerY = lineLabel.centerY
    }
    
    func initWeixinQQView(){
        weixinBtn = self.getUIButton()
        weixinBtn.setBackgroundImage(UIImage.init(named: "weixin_image"), for: .normal)
        weixinBtn.frame = CGRect(x:WHIDTH_RATIO()*66, y: lineLabel.originY+20*HEIGHT_RATIO(), width:WHIDTH_RATIO()*55 , height:WHIDTH_RATIO()*55)
        self.addSubview(weixinBtn)

        weixinLabel = UILabel.init(frame: CGRect(x:weixinBtn.originX, y: weixinBtn.originY+weixinBtn.height+10*HEIGHT_RATIO(), width:weixinBtn.width , height:HEIGHT_RATIO()*13))
        weixinLabel.text = "微信"
        weixinLabel.textColor = grayColor
        weixinLabel.font = UIFont.systemFont(ofSize: 13*WHIDTH_RATIO())
        weixinLabel.textAlignment = .center
        self.addSubview(weixinLabel)
        
        qqBtn = self.getUIButton()
        qqBtn.setBackgroundImage(UIImage.init(named: "qq_image"), for: .normal)
        qqBtn.frame = CGRect(x:SCREEN_WHIDTH()-WHIDTH_RATIO()*122, y: lineLabel.originY+20*HEIGHT_RATIO(), width:WHIDTH_RATIO()*55 , height:WHIDTH_RATIO()*55)
        self.addSubview(qqBtn)
        qqLabel = UILabel.init(frame: CGRect(x:qqBtn.originX, y: weixinBtn.originY+weixinBtn.height+10*HEIGHT_RATIO(), width:weixinBtn.width , height:HEIGHT_RATIO()*13))
        qqLabel.text = "QQ"
        qqLabel.textColor = grayColor
        qqLabel.font = UIFont.systemFont(ofSize: 13*WHIDTH_RATIO())
        qqLabel.textAlignment = .center
        self.addSubview(qqLabel)
        self.addSubview(weixinLabel)
        
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func getLinViewImage() -> UIImageView{
        let lineImageView = UIImageView.init()
        lineImageView.image = UIImage.init(named: "textViewLine_image")
        return lineImageView
    }
    

    func getUIButton() -> UIButton{
        let btn = UIButton.init(type: .custom)
        btn.contentMode = .scaleToFill
        return btn
    }
}
