55 lines
1.4 KiB
Swift
55 lines
1.4 KiB
Swift
//
|
|
// 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)
|
|
}
|
|
}
|