- 给全部 78 个 Swift 源文件添加详细的中文注释(文件级、类级、方法级) - 删除 LegacyRDReaderController/ 死代码目录(16 文件 4592 行) - 根目录翻页容器文件移入 ReaderView/ 目录 - Resources/ 移入 EPUBCore/Resources/(与使用者归属一致) - RDEPUBTextIndexTable.swift 移入 EPUBTextRendering/(消除反向依赖) - RDURLReaderController.swift 移入 EPUBUI/(入口控制器归入 UI 层) - 更新 podspec 资源路径
48 lines
1.4 KiB
Swift
48 lines
1.4 KiB
Swift
import UIKit
|
||
|
||
// MARK: - 工具栏基类
|
||
|
||
/// 阅读器工具栏的基类
|
||
/// 提供分隔线和主题适配的通用逻辑,子类只需关注具体功能按钮
|
||
open class RDEPUBReaderToolView: UIView {
|
||
/// 分隔线视图
|
||
private let lineView = UIView()
|
||
/// 分隔线高度
|
||
private let lineHeight: CGFloat = 0.5
|
||
|
||
override init(frame: CGRect) {
|
||
super.init(frame: frame)
|
||
translatesAutoresizingMaskIntoConstraints = false
|
||
addSubview(lineView)
|
||
}
|
||
|
||
public required init?(coder: NSCoder) {
|
||
fatalError("init(coder:) has not been implemented")
|
||
}
|
||
|
||
open override func layoutSubviews() {
|
||
super.layoutSubviews()
|
||
lineView.frame = lineFrame(in: bounds)
|
||
}
|
||
|
||
/// 应用主题配色到工具栏
|
||
/// - Parameter theme: 阅读器主题配置
|
||
open func apply(theme: RDEPUBReaderTheme) {
|
||
backgroundColor = .white
|
||
lineView.backgroundColor = UIColor.lightGray.withAlphaComponent(0.5)
|
||
}
|
||
|
||
/// 计算分隔线的位置和尺寸,子类可重写以调整分隔线位置(如顶部或底部)
|
||
/// - Parameter bounds: 工具栏的 bounds
|
||
/// - Returns: 分隔线的 frame
|
||
open func lineFrame(in bounds: CGRect) -> CGRect {
|
||
CGRect(x: 0, y: 0, width: bounds.width, height: lineHeight)
|
||
}
|
||
}
|
||
|
||
// MARK: - 工具栏按钮
|
||
|
||
/// 阅读器工具栏专用按钮
|
||
/// 继承自 UIButton,用于工具栏中的功能按钮
|
||
final class RDEPUBReaderTintButton: UIButton {
|
||
} |