100 lines
2.9 KiB
Swift
100 lines
2.9 KiB
Swift
//
|
|
// FAViewController.swift
|
|
// Fableon
|
|
//
|
|
// Created by 湖北秦九 on 2025/9/15.
|
|
//
|
|
|
|
import UIKit
|
|
import JXSegmentedView
|
|
|
|
class FAViewController: UIViewController, JXSegmentedListContainerViewListDelegate {
|
|
|
|
lazy var bgView: UIView = {
|
|
let view = UIImageView(image: UIImage(named: "背景"))
|
|
return view
|
|
}()
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
self.edgesForExtendedLayout = [.top]
|
|
|
|
if let navi = navigationController {
|
|
if navi.visibleViewController == self {
|
|
if navi.viewControllers.count > 1 {
|
|
configNavigationBack()
|
|
}
|
|
}
|
|
}
|
|
|
|
view.addSubview(bgView)
|
|
bgView.snp.makeConstraints { make in
|
|
make.edges.equalToSuperview()
|
|
}
|
|
}
|
|
|
|
|
|
func handleHeaderRefresh(_ completer: (() -> Void)?) {
|
|
completer?()
|
|
}
|
|
|
|
func handleFooterRefresh(_ completer: (() -> Void)?) {
|
|
completer?()
|
|
}
|
|
|
|
override var preferredStatusBarStyle: UIStatusBarStyle {
|
|
return .lightContent
|
|
}
|
|
|
|
|
|
func listView() -> UIView {
|
|
return self.view
|
|
}
|
|
}
|
|
|
|
|
|
extension UIViewController {
|
|
func configNavigationBack(_ imageName: String = "Frame 3011") {
|
|
let image = UIImage(named: imageName)
|
|
|
|
let leftBarButtonItem = UIBarButtonItem(image: image, style: .plain ,target: self,action: #selector(handleNavigationBack))
|
|
navigationItem.leftBarButtonItem = leftBarButtonItem
|
|
}
|
|
|
|
@objc func handleNavigationBack() {
|
|
self.fa_toLastViewController(animated: true)
|
|
}
|
|
|
|
func fa_toLastViewController(animated: Bool) {
|
|
if self.navigationController != nil
|
|
{
|
|
if self.navigationController?.viewControllers.count == 1
|
|
{
|
|
self.dismiss(animated: animated, completion: nil)
|
|
} else {
|
|
self.navigationController?.popViewController(animated: animated)
|
|
}
|
|
}
|
|
else if self.presentingViewController != nil {
|
|
self.dismiss(animated: animated, completion: nil)
|
|
}
|
|
}
|
|
}
|
|
|
|
extension UIViewController {
|
|
|
|
func fa_setNavigationStyle(backgroundColor: UIColor = .clear,
|
|
titleFont: UIFont = .font(ofSize: 18, weight: .bold),
|
|
titleColor: UIColor = .FFFFFF,
|
|
isTranslucent: Bool = true
|
|
) {
|
|
self.navigationController?.navigationBar.fa_setTranslucent(isTranslucent: isTranslucent)
|
|
self.navigationController?.navigationBar.fa_setBackgroundColor(backgroundColor: backgroundColor)
|
|
self.navigationController?.navigationBar.fa_setTitleTextAttributes(titleTextAttributes: [
|
|
NSAttributedString.Key.font : titleFont,
|
|
NSAttributedString.Key.foregroundColor : titleColor
|
|
])
|
|
}
|
|
|
|
}
|