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.
75 lines
2.1 KiB
75 lines
2.1 KiB
![]()
2 years ago
|
//
|
||
|
// MineHeaderView.swift
|
||
![]()
1 year ago
|
// 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)
|
||
![]()
2 years ago
|
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 = {
|
||
![]()
1 year ago
|
let img = UIImageView(image: R.image.white_arrow_icon())
|
||
![]()
2 years ago
|
return img
|
||
|
}()
|
||
|
|
||
|
override init(frame: CGRect) {
|
||
|
super.init(frame: frame)
|
||
![]()
2 years ago
|
gradient(colors: [kHexColor(0x59AAFF), kHexColor(0x2B75FF)], startPoint: CGPoint(x: 0, y: 0.5), endPoint: CGPoint(x: 1, y: 0.5), locations: nil)
|
||
![]()
2 years ago
|
setUpUI()
|
||
|
initHeaderView()
|
||
|
}
|
||
|
|
||
|
private func setUpUI() {
|
||
|
addSubview(userIconImg)
|
||
|
addSubview(userNameLabel)
|
||
|
addSubview(rightArrow)
|
||
|
}
|
||
|
|
||
|
private func initHeaderView() {
|
||
|
// 头像
|
||
|
userIconImg.snp.makeConstraints { (make) in
|
||
|
make.left.equalTo(30)
|
||
|
make.bottom.equalTo(-20)
|
||
|
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")
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|