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.
74 lines
2.1 KiB
74 lines
2.1 KiB
// |
|
// MineHeaderView.swift |
|
// Lookfit |
|
// |
|
// 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()) |
|
return img |
|
}() |
|
|
|
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) |
|
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") |
|
} |
|
|
|
} |
|
|
|
|