Files
suixinkan_ios_uikit/suixinkan_ios/Features/Main/Views/MainScanPlusButton.swift
汉秋 43179abf2c Fix TabBar icon assets and simplify Podfile post_install.
Rename tab icons to snake_case with @2x/@3x scales, register CYL plus button at app launch, and remove redundant Podfile hooks already covered by the Xcode project.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 18:49:37 +08:00

88 lines
3.2 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// MainScanPlusButton.swift
// suixinkan
//
import CYLTabBarController
import UIKit
@MainActor
@objcMembers
/// TabBar CYLTabBarController PlusButton
final class MainScanPlusButton: CYLPlusButton, CYLPlusButtonSubclassing {
/// `MainTabBarController`
static var onScanTap: (() -> Void)?
/// CYLTabBarController 使
static func plusButton() -> Any {
let button = MainScanPlusButton()
button.setImage(UIImage(named: "icon_scan"), for: .normal)
button.titleLabel?.textAlignment = .center
button.titleLabel?.font = UIFont.systemFont(ofSize: 10)
button.setTitle("发布", for: .normal)
button.setTitleColor(UIColor.gray, for: .normal)
button.setTitle("选中", for: .selected)
button.setTitleColor(UIColor(red:255.0/255.0,green:102.0/255.0,blue:0,alpha:1.0), for: .selected)
button.adjustsImageWhenHighlighted = false
button.sizeToFit()
return button
}
/// TabBar
static func indexOfPlusButtonInTabBar() -> UInt {
2
}
/// 使 TabBar
static func constantOfPlusButtonCenterYOffset(forTabBarHeight tabBarHeight: CGFloat) -> CGFloat {
-6
}
/// CustomMainTabBarCenterAction
private func configureAppearance() {
backgroundColor = .clear
let circleSize: CGFloat = 58
let circleView = UIView()
circleView.isUserInteractionEnabled = false
circleView.backgroundColor = AppDesign.primary
circleView.layer.cornerRadius = circleSize / 2
addSubview(circleView)
let symbolConfig = UIImage.SymbolConfiguration(pointSize: 30, weight: .bold)
let iconView = UIImageView(
image: UIImage(named: "icon_scan")
)
iconView.tintColor = .white
iconView.contentMode = .scaleAspectFit
iconView.isUserInteractionEnabled = false
addSubview(iconView)
circleView.translatesAutoresizingMaskIntoConstraints = false
iconView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
circleView.centerXAnchor.constraint(equalTo: centerXAnchor),
circleView.centerYAnchor.constraint(equalTo: centerYAnchor),
circleView.widthAnchor.constraint(equalToConstant: circleSize),
circleView.heightAnchor.constraint(equalToConstant: circleSize),
iconView.centerXAnchor.constraint(equalTo: circleView.centerXAnchor),
iconView.centerYAnchor.constraint(equalTo: circleView.centerYAnchor),
iconView.widthAnchor.constraint(equalToConstant: 30),
iconView.heightAnchor.constraint(equalToConstant: 30)
])
accessibilityLabel = "扫码核销"
accessibilityIdentifier = "main.scan"
}
///
@objc private func handleScanTap() {
Self.onScanTap?()
}
}