|
|
|
//
|
|
|
|
// MineHeaderView.swift
|
|
|
|
// FireBoltt
|
|
|
|
//
|
|
|
|
// Created by lemo. on 2020/4/3.
|
|
|
|
// Copyright © 2020 Sheldon. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
// MARK:- 常量
|
|
|
|
fileprivate struct Metric {
|
|
|
|
static let backgroundColor = kHexColor(0xC5D0DB, 0.2)
|
|
|
|
static let userNameColor = kHexColor(0xFFFFFF)
|
|
|
|
static let userNameFont = SystemSemiboldFont(20)
|
|
|
|
static let userIconWH = kScaleWidth(90)
|
|
|
|
}
|
|
|
|
|
|
|
|
class MineHeaderView: UIButton {
|
|
|
|
|
|
|
|
lazy var userIconImg: UIImageView = {
|
|
|
|
let img = UIImageView()
|
|
|
|
img.layer.cornerRadius = Metric.userIconWH / 2.0
|
|
|
|
img.layer.masksToBounds = true
|
|
|
|
return img
|
|
|
|
}()
|
|
|
|
lazy var userNameLabel: UILabel = {
|
|
|
|
let label = UILabel()
|
|
|
|
label.textColor = Metric.userNameColor
|
|
|
|
label.font = Metric.userNameFont
|
|
|
|
return label
|
|
|
|
}()
|
|
|
|
lazy var rightArrow: UIImageView = {
|
|
|
|
let img = UIImageView(image: R.image.white_arrow_icon())
|
|
|
|
return img
|
|
|
|
}()
|
|
|
|
|
|
|
|
lazy var bgView: UIView = {
|
|
|
|
let view = UIView()
|
|
|
|
view.gradient(colors: [kHexColor(0x59AAFF), kHexColor(0x2B75FF)], locations: nil, autoLaoutFrame: CGRect(x: 0, y: 0, width: kScreenW, height: kScaleWidth(180)))
|
|
|
|
return view
|
|
|
|
}()
|
|
|
|
|
|
|
|
override init(frame: CGRect) {
|
|
|
|
super.init(frame: frame)
|
|
|
|
//gradient(colors: [kHexColor(0x59AAFF), kHexColor(0x2B75FF)], startPoint: CGPoint(x: 0, y: 0.5), endPoint: CGPoint(x: 1, y: 0.5), locations: nil)
|
|
|
|
self.backgroundColor = .clear
|
|
|
|
setUpUI()
|
|
|
|
initHeaderView()
|
|
|
|
}
|
|
|
|
|
|
|
|
private func setUpUI() {
|
|
|
|
addSubview(bgView)
|
|
|
|
addSubview(userIconImg)
|
|
|
|
addSubview(userNameLabel)
|
|
|
|
addSubview(rightArrow)
|
|
|
|
}
|
|
|
|
|
|
|
|
private func initHeaderView() {
|
|
|
|
bgView.snp.makeConstraints { make in
|
|
|
|
make.left.right.equalTo(self)
|
|
|
|
make.top.equalTo(self)
|
|
|
|
make.bottom.equalTo(self.snp_bottom).inset(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 头像
|
|
|
|
userIconImg.snp.makeConstraints { (make) in
|
|
|
|
make.left.equalTo(30)
|
|
|
|
make.bottom.equalTo(-30)
|
|
|
|
make.width.height.equalTo(Metric.userIconWH)
|
|
|
|
}
|
|
|
|
// 用户名
|
|
|
|
userNameLabel.snp.makeConstraints { (make) in
|
|
|
|
make.centerY.equalTo(userIconImg.snp.centerY)
|
|
|
|
make.left.equalTo(userIconImg.snp.right).offset(10)
|
|
|
|
}
|
|
|
|
rightArrow.snp.makeConstraints { (make) in
|
|
|
|
make.centerY.equalTo(userNameLabel.snp.centerY)
|
|
|
|
make.right.equalTo(-20)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|