Commit c18bdf38 authored by pete谢兆麟's avatar pete谢兆麟

UI修改

parent be9872eb
......@@ -7,33 +7,32 @@
//
import UIKit
import AttributedString
class YHMakePlanBottomView: UIView {
// MARK: - UI Elements
private lazy var priceLabel: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 24, weight: .bold)
label.textColor = .black
label.textAlignment = .left
let a: ASAttributedString = .init("¥", .font(UIFont.PFSC_M(ofSize: 20)), .foreground(UIColor.mainTextColor))
let b: ASAttributedString = .init("58999.00", .font(UIFont.PFSC_M(ofSize: 28)), .foreground(UIColor.mainTextColor))
label.attributed.text = a + b
return label
}()
private lazy var priceButton: UIButton = {
let label = UIButton()
label.setTitle(">", for: .normal)
label.titleLabel?.font = UIFont.systemFont(ofSize: 16, weight: .medium)
label.setTitleColor(UIColor.systemBlue, for: .normal)
label.setImage(UIImage(named: "make_plan_up"), for: .normal)
label.addTarget(self, action: #selector(handleAction), for: .touchUpInside)
return label
}()
private lazy var actionButton: UIButton = {
let button = UIButton(type: .system)
button.setTitle("去办理 →", for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 16, weight: .medium)
button.setTitleColor(UIColor.systemBlue, for: .normal)
button.addTarget(self, action: #selector(handleAction), for: .touchUpInside)
private lazy var actionButton: YHImageTextButton = {
let button = YHImageTextButton(title: "去办理", image: UIImage(named: "make_plan_next"))
button.setTitleColor(UIColor(hex: 0xffffff), for: .normal)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
button.layer.cornerRadius = 2
button.backgroundColor = UIColor.mainTextColor
return button
}()
......@@ -41,7 +40,9 @@ class YHMakePlanBottomView: UIView {
var price: String = "" {
didSet {
priceLabel.text = "\(price)"
let a: ASAttributedString = .init("¥", .font(UIFont.PFSC_M(ofSize: 20)), .foreground(UIColor.mainTextColor))
let b: ASAttributedString = .init("\(price)", .font(UIFont.PFSC_M(ofSize: 28)), .foreground(UIColor.mainTextColor))
priceLabel.attributed.text = a + b
}
}
......
......@@ -7,6 +7,7 @@
//
import UIKit
import AttributedString
class YHMakePlanCardView: UIView {
......@@ -20,16 +21,16 @@ class YHMakePlanCardView: UIView {
private lazy var titleLabel: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 16, weight: .semibold)
label.textColor = .darkText
label.font = UIFont.PFSC_M(ofSize: 16)
label.textColor = .mainTextColor
label.numberOfLines = 1
return label
}()
private lazy var subtitleLabel: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 13, weight: .regular)
label.textColor = .gray
label.font = UIFont.PFSC_R(ofSize: 12)
label.textColor = UIColor(hex: 0x8993a2)
label.numberOfLines = 2
return label
}()
......@@ -40,25 +41,27 @@ class YHMakePlanCardView: UIView {
return view
}()
private lazy var storeButton: UIButton = {
let button = UIButton()
button.setTitle("星企航(7年)", for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 16, weight: .medium)
button.setTitleColor(UIColor.systemBlue, for: .normal)
private lazy var storeButton: YHImageTextButton = {
let button = YHImageTextButton(title: "星企航(7年)", image: UIImage(named: "make_plan_down"))
button.layer.cornerRadius = 2
button.backgroundColor = UIColor(hex: 0xf5f6f8)
// button.addTarget(self, action: #selector(handleAction), for: .touchUpInside)
return button
}()
private lazy var priceTagView: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 14, weight: .medium)
label.textColor = UIColor(red: 0.2, green: 0.4, blue: 0.8, alpha: 1.0)
let a: ASAttributedString = .init("¥", .font(UIFont.PFSC_M(ofSize: 14)), .foreground(UIColor.mainTextColor))
let b: ASAttributedString = .init("58999.00", .font(UIFont.PFSC_M(ofSize: 20)), .foreground(UIColor.mainTextColor))
label.attributed.text = a + b
return label
}()
private lazy var selectButton: UIButton = {
let button = UIButton()
button.backgroundColor = .red
button.setImage(UIImage(named: "make_plan_select"), for: .selected)
button.setImage(UIImage(named: "make_plan_normal"), for: .normal)
// button.addTarget(self, action: #selector(handleAction), for: .touchUpInside)
return button
}()
......@@ -110,13 +113,14 @@ class YHMakePlanCardView: UIView {
make.height.width.equalTo(86)
}
storeButton.translatesAutoresizingMaskIntoConstraints = false
storeButton.snp.makeConstraints { make in
make.top.equalToSuperview().offset(60)
make.left.equalToSuperview().offset(110)
make.width.equalTo(97)
// make.width.equalTo(97)
make.height.equalTo(22)
}
priceTagView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(86)
make.left.equalToSuperview().offset(110)
......@@ -127,6 +131,7 @@ class YHMakePlanCardView: UIView {
make.right.bottom.equalTo(-18)
make.height.width.equalTo(16)
}
}
// MARK: - Configuration
......@@ -135,6 +140,7 @@ class YHMakePlanCardView: UIView {
titleLabel.text = data.title
subtitleLabel.text = data.subtitle
priceTagView.text = data.price
storeButton.updateContent()
}
}
......@@ -146,3 +152,76 @@ struct CompanyPackageData {
let price: String
let showCheckmark: Bool
}
class YHImageTextButton: UIButton {
var spacing: CGFloat = 4 // 文字和图片之间的间距
var horizontalPadding: CGFloat = 8 // 左右边距
init(title: String, image: UIImage?) {
super.init(frame: .zero)
// 基础配置
setTitle(title, for: .normal)
setImage(image, for: .normal)
setTitleColor(UIColor(hex: 0x6a7586), for: .normal)
titleLabel?.font = UIFont.PFSC_R(ofSize: 12)
// 关键配置:图片在右侧
semanticContentAttribute = .forceRightToLeft
contentHorizontalAlignment = .center
// 禁用系统默认的inset调整
adjustsImageWhenHighlighted = false
imageView?.translatesAutoresizingMaskIntoConstraints = false
titleLabel?.translatesAutoresizingMaskIntoConstraints = false
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// 关键:正确计算固有内容大小
override var intrinsicContentSize: CGSize {
let titleSize = titleLabel?.intrinsicContentSize ?? .zero
let imageSize = imageView?.intrinsicContentSize ?? .zero
// 总宽度 = 文字宽度 + 图片宽度 + 间距 + 左右边距×2
let totalWidth = titleSize.width + imageSize.width + spacing + 2 * horizontalPadding
let maxHeight = max(titleSize.height, imageSize.height)
return CGSize(width: totalWidth, height: maxHeight)
}
// 关键:手动布局子视图
override func layoutSubviews() {
super.layoutSubviews()
guard let titleLabel = titleLabel, let imageView = imageView else { return }
// 手动计算布局
let totalContentWidth = titleLabel.intrinsicContentSize.width + spacing + imageView.intrinsicContentSize.width
let startX = (bounds.width - totalContentWidth) / 2
// 定位文字和图片
titleLabel.frame = CGRect(
x: startX,
y: (bounds.height - titleLabel.intrinsicContentSize.height) / 2,
width: titleLabel.intrinsicContentSize.width,
height: titleLabel.intrinsicContentSize.height
)
imageView.frame = CGRect(
x: titleLabel.frame.maxX + spacing,
y: (bounds.height - imageView.intrinsicContentSize.height) / 2,
width: imageView.intrinsicContentSize.width,
height: imageView.intrinsicContentSize.height
)
}
// 在文本或图片变化时调用
func updateContent() {
invalidateIntrinsicContentSize()
setNeedsLayout()
}
}
......@@ -25,7 +25,7 @@ class YHMakePlanCusttomHeadView: UIView {
private let underlineView: UIView = {
let view = UIView()
view.backgroundColor = .systemBlue
view.backgroundColor = UIColor.mainTextColor
return view
}()
......@@ -51,7 +51,7 @@ class YHMakePlanCusttomHeadView: UIView {
let button = UIButton(type: .system)
button.setTitle(title, for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 14)
button.setTitleColor(index == 0 ? .systemBlue : .gray, for: .normal)
button.setTitleColor(index == 0 ? UIColor.mainTextColor: UIColor(hex: 0x6a7586), for: .normal)
button.tag = index
button.addTarget(self, action: #selector(tabTapped(_:)), for: .touchUpInside)
buttons.append(button)
......@@ -72,8 +72,8 @@ class YHMakePlanCusttomHeadView: UIView {
underlineView.snp.makeConstraints { make in
make.top.equalTo(stackView.snp.bottom)
make.height.equalTo(2)
make.width.equalToSuperview().dividedBy(tabs.count)
make.leading.equalToSuperview()
make.width.equalTo(16)
make.centerX.equalTo(buttons[0].snp.centerX)
}
}
......@@ -83,13 +83,16 @@ class YHMakePlanCusttomHeadView: UIView {
guard newIndex != selectedIndex else { return }
// Update colors
buttons[selectedIndex].setTitleColor(.gray, for: .normal)
buttons[newIndex].setTitleColor(.systemBlue, for: .normal)
buttons[selectedIndex].setTitleColor(UIColor(hex: 0x6a7586), for: .normal)
buttons[newIndex].setTitleColor(UIColor.mainTextColor, for: .normal)
// Animate underline
UIView.animate(withDuration: 0.3) {
self.underlineView.snp.updateConstraints { make in
make.leading.equalToSuperview().offset(sender.frame.origin.x)
self.underlineView.snp.remakeConstraints { make in
make.top.equalTo(self.stackView.snp.bottom)
make.height.equalTo(2)
make.width.equalTo(16)
make.centerX.equalTo(self.buttons[newIndex].snp.centerX)
}
self.layoutIfNeeded()
}
......
......@@ -52,7 +52,10 @@ class YHMakePlanShareAlertView: UIView {
sureButton = {
let button = UIButton(type: .custom)
button.backgroundColor = .black
button.backgroundColor = UIColor(hex: 0xf5f6f8)
button.setTitleColor(.mainTextColor, for: .normal)
button.setTitle("取消", for: .normal)
button.layer.cornerRadius = 4
button.addTarget(self, action: #selector(dismiss), for: .touchUpInside)
return button
}()
......@@ -80,7 +83,7 @@ class YHMakePlanShareAlertView: UIView {
rightButton = {
let button = YHShareButton()
button.setContent("invitation_with_gifts_share_center", "复制链接")
button.setContent("invitation_with_gifts_share_link", "复制链接")
button.addTarget(self, action: #selector(wxClick), for: .touchUpInside)
return button
}()
......
......@@ -14,8 +14,8 @@ class YHMakePlanStateHeadView: UIView {
private let yearsLabel: UILabel = {
let label = UILabel()
label.text = "5"
label.font = .boldSystemFont(ofSize: 32)
label.textColor = .label
label.font = UIFont.PFSC_M(ofSize: 32)
label.textColor = .mainTextColor
label.textAlignment = .center
return label
}()
......@@ -23,8 +23,8 @@ class YHMakePlanStateHeadView: UIView {
private let yearsDescriptionLabel: UILabel = {
let label = UILabel()
label.text = "预计可续期(年)"
label.font = .systemFont(ofSize: 14)
label.textColor = .secondaryLabel
label.font = UIFont.PFSC_M(ofSize: 14)
label.textColor = UIColor(hex: 0x8893a2)
label.textAlignment = .center
return label
}()
......@@ -32,8 +32,8 @@ class YHMakePlanStateHeadView: UIView {
private let percentageLabel: UILabel = {
let label = UILabel()
label.text = "90%"
label.font = .boldSystemFont(ofSize: 32)
label.textColor = .label
label.font = UIFont.PFSC_M(ofSize: 32)
label.textColor = .mainTextColor
label.textAlignment = .center
return label
}()
......@@ -41,8 +41,8 @@ class YHMakePlanStateHeadView: UIView {
private let progressDescriptionLabel: UILabel = {
let label = UILabel()
label.text = "续签综合通过率"
label.font = .systemFont(ofSize: 14)
label.textColor = .secondaryLabel
label.font = UIFont.PFSC_M(ofSize: 14)
label.textColor = UIColor(hex: 0x8893a2)
label.textAlignment = .center
return label
}()
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "invitation_with_gifts_share_link@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "invitation_with_gifts_share_link@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "make_plan_down@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "make_plan_down@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "make_plan_next@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "make_plan_next@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "make_plan_normal@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "make_plan_normal@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "make_plan_select@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "make_plan_select@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "make_plan_up@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "make_plan_up@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment