You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.7 KiB

2 years ago
//
// MineHeaderView.swift
// FireBoltt
2 years ago
//
// 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)
2 years ago
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())
2 years ago
return img
}()
lazy var bgView: UIButton = {
let btn = UIButton(type: .custom).then {
$0.setTitleColor(.white, for: .normal)
}
btn.gradient(colors: [kHexColor(0x59AAFF), kHexColor(0x2B75FF)], startPoint: CGPoint(x: 0, y: 0.5), endPoint: CGPoint(x: 1, y: 0.5), locations: [0, 1], autoLaoutFrame: CGRect(x: 0, y: 0, width: kScreenW, height: kScaleWidth(180)))
return btn
}()
2 years ago
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
2 years ago
setUpUI()
initHeaderView()
}
private func setUpUI() {
addSubview(bgView)
2 years ago
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);
}
2 years ago
//
userIconImg.snp.makeConstraints { (make) in
make.left.equalTo(30)
make.bottom.equalTo(-30)
2 years ago
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")
}
}