Epub阅读器0.0.1
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// RDReaderTopToolView.swift
|
||||
// RDReaderDemo
|
||||
//
|
||||
// Created by yangsq on 2021/8/10.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import SnapKit
|
||||
|
||||
|
||||
|
||||
public class RDReaderTopToolView: RDReaderToolView,SSEventTrigger {
|
||||
|
||||
|
||||
enum Event {
|
||||
case back
|
||||
}
|
||||
public override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
lineView.frame = CGRect(x: 0, y: frame.height - lineHeight, width: frame.width, height: lineHeight)
|
||||
}
|
||||
|
||||
lazy var backButton: TintColorButton = {
|
||||
let backButton = TintColorButton(type: .system)
|
||||
backButton.setImage(toolbarImage(named: "arrow_left", fallbackSystemName: "chevron.left"), for: .normal)
|
||||
return backButton
|
||||
}()
|
||||
|
||||
override func makeUI() {
|
||||
super.makeUI()
|
||||
addSubview(backButton)
|
||||
backButton.addTarget(self, action: #selector(backAction), for: .touchUpInside)
|
||||
backButton.snp.makeConstraints { make in
|
||||
make.left.equalTo(0)
|
||||
make.bottom.equalTo(0)
|
||||
make.height.equalTo(44)
|
||||
make.width.equalTo(50)
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func backAction() {
|
||||
if let trigger = self.triggerEvent {
|
||||
trigger(.back)
|
||||
}
|
||||
}
|
||||
|
||||
private func toolbarImage(named: String, fallbackSystemName: String) -> UIImage? {
|
||||
if let image = UIImage(named: named) {
|
||||
return image.withRenderingMode(.alwaysOriginal)
|
||||
}
|
||||
return UIImage(systemName: fallbackSystemName)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user