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.
102 lines
3.3 KiB
102 lines
3.3 KiB
![]()
2 years ago
|
//
|
||
|
// HealthNavigationBar.swift
|
||
|
// Lookfit
|
||
|
//
|
||
|
// Created by lemo. on 2020/4/6.
|
||
|
// Copyright © 2020 Sheldon. All rights reserved.
|
||
|
//
|
||
|
|
||
|
import UIKit
|
||
|
|
||
|
// MARK:- 常量
|
||
|
fileprivate struct Metric {
|
||
|
static let backgroundColor = kHexColor(0xFBFBFB)
|
||
|
static let titleFont = SystemRegularFont(18)
|
||
|
static let otherColor = kHexColor(0x000000)
|
||
|
static let otherFont = SystemRegularFont(10)
|
||
|
}
|
||
|
|
||
|
class HealthNavigationBar: UIButton {
|
||
|
|
||
|
lazy var headImg: UIImageView = {
|
||
|
let img = UIImageView()
|
||
|
img.layer.cornerRadius = kScaleWidth(45) / 2.0
|
||
|
img.layer.masksToBounds = true
|
||
|
return img
|
||
|
}()
|
||
|
lazy var nicknameLabel: UILabel = {
|
||
|
let label = UILabel()
|
||
|
label.textColor = kHexColor(0x2A2A2A)
|
||
|
label.font = SystemRegularFont(17)
|
||
|
return label
|
||
|
}()
|
||
|
lazy var rightArrow: UIImageView = {
|
||
|
let img = UIImageView(image: R.image.icon_arrow_down())
|
||
|
return img
|
||
|
}()
|
||
|
lazy var statusBtn: UIButton = {
|
||
|
let btn = UIButton(type: .custom).then {
|
||
|
$0.setTitleColor(Metric.otherColor, for: .normal)
|
||
|
$0.titleLabel?.font = Metric.otherFont
|
||
|
$0.imageEdgeInsets = UIEdgeInsets(top: 0, left: -10, bottom: 0, right: 0)
|
||
|
addSubview($0)
|
||
|
}
|
||
|
btn.setImage(R.image.icon_watch_notConnect(), for: .normal)
|
||
|
btn.setTitle(MultiLanguageKey.disConnected.localized, for: .normal)
|
||
|
btn.setImage(R.image.icon_watch_connect(), for: .selected)
|
||
|
btn.setTitle(MultiLanguageKey.coonected.localized, for: .selected)
|
||
|
return btn
|
||
|
}()
|
||
|
lazy var powerBtn: UIButton = {
|
||
|
let btn = UIButton(type: .custom).then {
|
||
|
$0.setTitleColor(Metric.otherColor, for: .normal)
|
||
|
$0.titleLabel?.font = Metric.otherFont;
|
||
|
$0.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: -10)
|
||
|
addSubview($0)
|
||
|
}
|
||
|
btn.setImage(R.image.power_0(), for: .normal)
|
||
|
btn.setTitle(MultiLanguageKey.power.localized, for: .normal)
|
||
|
return btn
|
||
|
}()
|
||
|
|
||
|
override init(frame: CGRect) {
|
||
|
super.init(frame: frame)
|
||
|
addSubview(headImg)
|
||
|
addSubview(nicknameLabel)
|
||
|
addSubview(rightArrow)
|
||
|
addSubview(statusBtn)
|
||
|
addSubview(powerBtn)
|
||
|
setUpUI()
|
||
|
}
|
||
|
|
||
|
func setUpUI() {
|
||
|
headImg.snp.makeConstraints { (make) in
|
||
|
make.left.equalTo(15)
|
||
|
make.top.equalTo(kBatteryH + 10)
|
||
|
make.width.height.equalTo(kScaleWidth(45))
|
||
|
}
|
||
|
nicknameLabel.snp.makeConstraints { (make) in
|
||
|
make.centerY.equalTo(headImg.snp.centerY)
|
||
|
make.left.equalTo(headImg.snp.right).offset(kScaleWidth(10))
|
||
|
}
|
||
|
rightArrow.snp.makeConstraints { (make) in
|
||
|
make.centerY.equalTo(headImg.snp.centerY)
|
||
|
make.left.equalTo(nicknameLabel.snp.right).offset(kScaleWidth(10))
|
||
|
}
|
||
|
powerBtn.snp.makeConstraints { (make) in
|
||
|
make.right.equalTo(-15)
|
||
|
make.centerY.equalTo(headImg.snp.centerY)
|
||
|
}
|
||
|
statusBtn.snp.makeConstraints { (make) in
|
||
|
make.right.equalTo(powerBtn.snp.left).offset(-15)
|
||
|
make.centerY.equalTo(headImg.snp.centerY)
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
required init?(coder: NSCoder) {
|
||
|
fatalError("init(coder:) has not been implemented")
|
||
|
}
|
||
|
|
||
|
}
|